Syntax
new Ajax.Updater(container, url, options);
// make a HTTP request to the specified URL and update the 'container' element.
new Ajax.Updater(container, url, options);
// make a HTTP request to the specified URL and update the 'container' element.
Note: to only update a div on success, you may optionally substitute a property list for a simply element id (ie {success:’div_name’} instead of ‘div_name’)
Options
Option | Default value | Description |
asynchronous | true | Type of request |
evalScripts | false | When set as “true”, scripts in requested url are evaluated |
method | ‘post’ | Lets you decide whether to use Get or Post for the request to the server |
contentType | ‘application/x-www-form-urlencoded’ | Allows you to set the content-type sent to the server |
encoding | ‘UTF-8’ | Allows you to determine the encoding type information given to the server |
parameters | ’’ | Allows you to attach parameters to your AJAX request. Most common: parameters:Form.serialize(this) |
postBody | ’’ | Specify data to post. Something like: postBody:’thisvar=true&thatvar=Howdy’ How does this differ from parameters? |
username | ’’ | |
password | ’’ | |
requestHeaders | ’’ | Allows you to override the headers, see the Prototype AJAX options for details |
onComplete | ’’ | Function to call on completion of request |
onSuccess | ’’ | Function to call on successful completion of request |
onFailure | ’’ | Function to call on failed request |
onException | ’’ | Function to call on failed request (e.g. attempted cross-site request) |
on + Status Code | ’’ | on404 etc. raise an event when given status code is encountered. |
insertion | None | Instead of inserting the response in the existing content (possibly overwriting it) you can pass a valid Insertion object, such as Insertion.Top, Insertion.Bottom, Insertion.Before or Insertion.After. |
Hint: If you have set evalScripts:true the script you call (the url parameter) must return a header of ‘Content-Type: text/javascript’ else the browser will not execute it.