I spent the best part of the morning trying to figure out why a simple Ajax call with MooTools wouldn’t work correctly.
I was either getting no response and various script errors caught in
FireBug, or jumping straight to the target URL, no Ajax happening.
I would have wasted more time trying to fix bugs in this had I not tried to do the same thing in jQuery.
With jQuery, it took me all of 1 minute to produce the desired result.
I haven’t really spent any time with JavaScript before and only hear from friends which framework they like best.
I’m sure for different things each has its own strengths, but I am adding a vote of confidence to jQuery!
Here’s the simple code to get a DIV replaced with the output of a PHP call:
HTML file contents
Your Page Title
Click to load content from PHP
PHP output will be shown here
This will replace the contents of the DIV with whatever is output normally by the PHP script.
You will need to download and add the jquery.js file to the same
folder as this file. You will also need to put your php file in the same
folder and run it all on a web server to see results.
To learn about running a test web server for free on your own computer, please browse my other posts.