DOMAssistant.AJAX Module
The DOMAssistantAJAX module offers basic AJAX interaction for retrieving data from a URL and then passing on the returned content to any function, or load the content into an element.
get(url, callBack)
Makes a GET request to the specified URL and calls the set callBack function. The first parameter of the then called callBack function will be the responseText
of the AJAX call. If this method is called on an element, the callBack function context will be the element, i.e. the keyword this
will refer to the element which called the get
method in the first place.
Parameters
- url
- URL to make an AJAX call to. Required.
- callBack
- Function name or anonymous function to call when the AJAX request is complete. Optional.
Return value
None.
Example calls
$("news").get("news.php", insertNews);
DOMAssistant.AJAX.get("my-url.aspx", callbackFunctionName);
post(url, callBack)
Makes a POST request to the specified URL and calls the set callBack function. The first parameter of the then called callBack function will be the responseText
of the AJAX call. If this method is called on an element, the callBack function context will be the element, i.e. the keyword this
will refer to the element which called the get
method in the first place.
Parameters
- url
- URL to make an AJAX call to. Required.
- callBack
- Function name or anonymous function to call when the AJAX request is complete. Optional.
Return value
None.
Example calls
$("news").post("news.php?value=true", insertNews);
DOMAssistant.AJAX.post("my-url.aspx?number=10", callbackFunctionName);
load(url, add)
Makes a request to the specified URL and loads the returned content into the element which the method is called on.
Parameters
- url
- URL to make an AJAX call to. Required.
- add
- A boolean, if the retrieved content shall be appended to the already existing content, as opposed to replacing it. Optional.
Return value
None.
Example calls
$("directions").load("maps.php");
$("contacts", true).load("staff.aspx");
getReadyState()
Helper method to check the current readyState
of the XMLHttpRequest.
Parameters
None
Return value
Integer.
- 0 = uninitialized
- 1 = loading
- 2 = loaded
- 3 = interactive
- 4 = complete
Example calls
DOMAssistant.AJAX.getReadyState();
getStatus()
Helper method to check the current status
of the XMLHttpRequest.
Parameters
None
Return value
Integer. Examples are 200 for Ok and 404 for not found.
Example calls
DOMAssistant.AJAX.getStatus();
getStatusText()
Helper method to check the current readyState
of the XMLHttpRequest.
Parameters
None
Return value
String. The text accompanying the status code.
Example calls
DOMAssistant.AJAX.getStatusText();
DOMAssistant.AJAX methods
DOMAssistant modules
- DOMAssistant Core
- DOMAssistant.AJAX
- DOMAssistant.Content
- DOMAssistant.CSS
- DOMAssistant.Events
- DOMAssistant.Load
CSS selectors
Download DOMAssistant
All modules in one file
-
DOMAssistant 2.5.7, compressed
(22kb, 7kb Gzipped) - Intended for production usage.
-
DOMAssistant 2.5.7, complete
(43kb) - Intended for learning and development usage.