Contains the ajax class. Also contains methods to generate querystings from forms and Objects.
Moo.js, Function.js, Array.js, String.js, Element.js
Valerio Proietti, http://mad4milk.net
MIT-style license.
| Ajax.js | Contains the ajax class. |
| Ajax | For all your asynchronous needs. |
| Properties | |
| request | Executes the ajax request. |
| evalScripts | Executes scripts in the response text |
| Object related Functions | |
| Functions | |
| Object. toQuerySTring | Generates a querysting from a key/pair values in an object |
| Element | Custom class to allow all of its methods to be used with any DOM element via the dollar function $. |
| Properties | |
| send | Sends a form with an ajax post request |
| toQueryString | Reads the children inputs of the Element and generates a query string, based on their values. |
For all your asynchronous needs. Note: this class implements Chain
| url | the url pointing to the server-side script. |
| options | optional, an object containing options. |
| method | ’post’ or ‘get’ - the prototcol for the request; optional, defaults to ‘post’. |
| postBody | if method is post, you can write parameters here. Can be a querystring, an object or a Form element. |
| async | boolean: asynchronous option; true uses asynchronous requests. Defaults to true. |
| onComplete | function to execute when the ajax request completes. |
| onStateChange | function to execute when the state of the XMLHttpRequest changes. |
| update | $(element) to insert the response text of the XHR into, upon completion of the request. |
| evalScripts | boolean; default is false. Execute scripts in the response text onComplete. |
var myAjax = new Ajax(url, {method: 'get'}).request();
| Properties | |
| request | Executes the ajax request. |
| evalScripts | Executes scripts in the response text |
Executes the ajax request.
var myAjax = new Ajax(url, {method: 'get'});
myAjax.request();
OR
new Ajax(url, {method: 'get'}).request();| Functions | |
| Object. toQuerySTring | Generates a querysting from a key/pair values in an object |
Generates a querysting from a key/pair values in an object
| source | the object to generate the querystring from. |
the query string.
Object.toQueryString({apple: "red", lemon: "yellow"}); //returns "apple=red&lemon=yellow"Custom class to allow all of its methods to be used with any DOM element via the dollar function $.
| Properties | |
| send | Sends a form with an ajax post request |
| toQueryString | Reads the children inputs of the Element and generates a query string, based on their values. |
Sends a form with an ajax post request
| options | option collection for ajax request. See <Ajax.initialize> for option list. |
The Ajax Class Instance
<form id="myForm" action="submit.php">
<input name="email" value="bob@bob.com">
<input name="zipCode" value="90210">
</form>
<script>
$('myForm').send()
</script>
Reads the children inputs of the Element and generates a query string, based on their values. Used internally in Ajax
<form id="myForm" action="submit.php">
<input name="email" value="bob@bob.com">
<input name="zipCode" value="90210">
</form>
<script>
$('myForm').toQueryString()
</script>
email=b.nosp@m.ob@bob.nosp@m..com&zipCode=90210
returns the element passed in with all the Element prototypes applied.
function $( el )
function $A( array )