jQuery-ahm is a tiny (~1kb) jQuery plugin which enables us to create Ajax requests with a smaller code piece.
It is actually a wrapper around the popular $.ajax
method and brings a different way of handling callbacks.
Rather than creating custom callbacks for every Ajax request, jQuery-ahm lets the back-end define Ajax callbacks (handled automatically).
Features
jquery-ahm is a replacement for $.ajax. With $.ajax, every ajax request needs a callback, resulting in a lot of javascript. $.ahm reduces javascript code by letting the response data define the actual callbacks.
- Super light-weight: ~1KB minified
- Reduces ajax requests to one-line (including ajax form validation)
- No more custom callbacks for every ajax request
- Lets back-end define post ajax callbacks (applied automagically)
- Supports all jquery + custom callbacks in back-end code
- Drop in replacement for $.ajax() (supports all $.ajax options)
Here is an example where all the callback is handled on the server-side:
01.
<?php
02.
$response
=
array
(
03.
// $("#animate").fadeOut("slow").delay("1000").slideDown("fast")
04.
"#animate/fadeOut"
=>
"slow"
,
05.
"#animate/delay"
=>
"1000"
,
06.
"#animate/slideDown"
=>
"fast"
,
07.
);
08.
echo
json_encode(
$response
);
09.
?>
The bad part is, you move the front-end code and functionality to the server-side. This is not a preferred method for many designers/developers and it is mostly difficult if the front and back-end developers are different persons.
And the nice part is, size of the front-end code can be decreased seriously, specially for websites with lots of Ajax interactions and you get lots of flexibility in managing the callbacks.
Requirements: jQuery
Website: http://www.jqueryahm.com/
Demo: http://www.jqueryahm.com/examples
Download: http://www.jqueryahm.com/download