A simple wrapper for jQuery methods to make AJAX forms into 1-liners.
In it's simplest form you should only need the following line:
$('form').ajaxify();
Which would make all the forms on the current page run AJAX requests and update their parent nodes.
You can specify options to the function call:
$('form').ajaxify({
'append': 'ajax=1', // this will be appended to the URLs requested (default: ajax=1)
'async': true, // runs the request asynchonously (default: true)
'contentType': null, // the content type to send the data as (default: application/x-www-form-urlencoded)
'dataType': 'html', // the type of data returned (default: html)
'type': null, // the type of request GET/POST (form default: method attribute, link default: GET)
'update': null, // the element to fill with the returned data (default: parent element)
'url': null // the url to request (form default: action attribute, link default: href attribute)
});
Note: When the form is replaced, you will need to make another call to $('form').ajaxify(); to ensure the form is submitted using AJAX again. You could include <script type="text/javascript">$('form').ajaxify();</script> in the data returned by the AJAX request to ensure this, but there are other ways I'm sure. Unfortunately the .live() method currently doesn't support submit. :(