Ajax class provides ability to make asynchronous HTTP request to the server
var ajax = new Ajax("index.html", "GET", true);
ajax.send().then(
function (value) {
console.log(value);
},
function (reason) {
console.log(reason);
});
string
| Object
Specifies the data to be sent.
Defaults to null
XMLHttpRequest
Specifies the callback for creating the XMLHttpRequest object.
Defaults to null
boolean
A boolean value indicating whether the request should be sent asynchronous or not.
Defaults to true
string
Specifies which HTTP request method to be used. For ex., GET, POST
Defaults to GET
string
Specifies the URL to which request to be sent.
Defaults to null
To get the response header from XMLHttpRequest
Parameter | Type | Description |
---|---|---|
key | string |
Key to search in the response header |
Returns string
Send the request to server.
Parameter | Type | Description |
---|---|---|
data (optional) | string | Object |
To send the user data |
Returns Promise
Function
Specifies the callback function to be triggered before sending request to sever. This can be used to modify the XMLHttpRequest object before it is sent.
Function
Triggers when XmlHttpRequest is failed.
Function
Specifies callback function to be triggered after XmlHttpRequest is succeeded. The callback will contain server response as the parameter.