I’ve used AJAX a lot in PHP, but now I’m trying to learn CakePHP, and haven’t been able to ANY good/simple examples of how to use AJAX with CakePHP 1.3. The only examples I’ve been able to find are for paging (not what I need), or use the deprecated helpers while forcing you to include scriptaculous or prototype.
Are there ANY good/simple examples of how to use AJAX w/ CakePHP 1.3? Or is it something someone could explain here?
All I want to do is have the user click a link, which retrieves the contents of a php file, and inserts it into a div. The contents of the php file would be altered based on some POST or GET variables sent w/ the ajax call. Seems simple enough 🙁
This is the pattern that I use in CakePHP 1.3.x. The process is generally:
Be sure to include RequestHandler component and JsHelper in your app controller.
In a given controller:
Your app/views/layouts/json.ctp file:
Your app/views/controllername/ajax_test.ctp file should contain only:
Now, on your page that’s actually going to make an ajax call, it might look something like this, with jQuery code: