Flamingo.Ajax.jQuery.mobile.catchAjaxRequests()¶
The catchAjaxRequests() method will catch all AJAX requests made by jQuery for preprocessing. If arguments are omitted, it will preprocess the response by Flamingo.Ajax.processHTMLString and call original callback with the converted HTML string as an argument. If successCb or errorCb parameters are specified, it will not process the response using Flamingo.Ajax.processHTMLString. In that case you can add processing manually.
Note
The Flamingo.Ajax.jQuery.mobile.catchAjaxRequests() method is designed to use with the jQuery mobile UI framework.
Syntax¶
Flamingo.Ajax.jQuery.mobile.catchAjaxRequests([successCb, errorCb])
Parameters¶
Parameter | Description |
---|---|
successCb | Callback function for all successful AJAX requests made with jQuery. |
errorCb | Callback function for all AJAX requests made with jQuery that were resolved with an error. |
Example 1¶
The example below demonstrates how to call the catchAjaxRequests() method to catch AJAX requests.
Flamingo.Ajax.jQuery.mobile.catchAjaxRequests();
Example 2¶
The following example shows how to process successful requests and the requests that resulted in error.
Flamingo.Ajax.jQuery.mobile.catchAjaxRequests(
function(data, status, jqXHR) {
//process error
alert("error");
},
function(data, status, jqXHR) {
//process successful request using the Flamingo.Ajax.processHTMLString method
Flamingo.Ajax.processHTMLString("http://example.com/ajaxcontent.html", data, function(html) {
document.getElementById('ajaxContent').innerHTML = html;
})
}
);
See also