Wednesday, August 8, 2012

Re: Problems with ajax and security component.

I am struggling with the exact same problem..

If anyone have a suggestion???
see: http://stackoverflow.com/questions/11869336/cakephp-2-1-making-a-jquery-ajax-call-with-security-component-activated

-Tom


kl. 21:41:18 UTC+1 torsdag 8. desember 2011 skrev porangi.chris følgende:
Hi,

I'm having issues with running Ajax and the security component
alongside each other.  Security works fine on the other forms.  Ajax
works fine if Security is commented out.

Security is included in the App Controller alongside other components

        'Security' => array(
            'csrfExpires' => '+2 hour'
        )

and I've added the line into AppController:BeforeFilter.

$this->Security->blackHoleCallback = '_fail';

I've tried this in the beforeFilter function of the controller but not
work:

if(isset($this->Security) && $this->action == 'tracker') {
 $this->Security->csrfCheck = false;
}

basically I have a ajax query which fails:

        function update_log() {
            //This is our ajax call.
            jQuery.ajax({
                type: 'POST',
                url: "<?php echo Configure::read('Link.site'); ?>/logs/
tracker",
                data : {"lat": latitude, "lon":longitude,
"resource":resource},
                dataType : 'json',
                success: function(data) {
                    jQuery('input#logid').val(data.log);
                }
            }); //End Visitor Code

I tried to construct a hidden form which I serialised and sent which
had the tokens but this failed too.

Please help - this needs to go live :(

Thanks

Chris

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: