Sunday, February 2, 2014

Re: jQuery sortable: how to update database?

Allright, that will be much easier to understand the whole AJAX and request happening! Last years, I've realy struggled with this and I think it will be a lot clearer for me now. Thank you!
To go back on my sorting problem: it isn't working yet. I dugged into CakePHP's Request Handling documentation and tried to catch the POST values from that AJAX request. The strange thing is that my controller seems to haven't catched a request at all! Here's my controller code:

class AttractionsController extends CoasterCmsAppController
{
    public $components = array(
        'RequestHandler'
    );
...
    public function beforeFilter() {
        if ($this->RequestHandler->isAjax) {
            echo 'Ajax';
        } elseif ($this->RequestHandler->isPost) {
            echo 'Post';
        } elseif  ($this->RequestHandler->isGet) {
            echo 'Get';
        } else {
            echo 'Damn, this string shouldn't be here!';
        }
    }
}

As you can guess, I always got the string "Damn, this string shouldn't be here!" outputted (instead of the "Ajax" echo). However, my javascript has no errors and I do get my data when I alert it in the "succeed" of my $.ajax. Is there something crucial that I'm forgetting? :)


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: