Default settings
var _azAjaxOptions =
{
azAjaxUrl: "",
azAjaxDataType: "json",
azAjaxType: "POST",
azAjaxContentType: "application/json; charset=utf-8",
azAjaxObjHeaders: {},
azAjaxTimeout: 15000,
azAjaxObjToSend: {},
};
Features
There are several ways to use AZAjax.
new AZAjax(_azAjaxOptions).always(function (data, textStatus, jqXHR)
{
// Here you put the logic for handling "always", "done", "fail", etc.
});
You can also have functions that listen to whether AZAjax has received data or has failed.
var azAjax1 = new AZAjax(_azAjaxOptions);
azAjax1.done(function (data, textStatus, jqXHR)
{
if (jqXHR.status === 200)
{
// Here you put the logic for handling "done".
}
});
azAjax1.always(function (data, textStatus, jqXHR)
{
// Here you put the logic for handling any errors.
if (jqXHR.status === 404)
{
}
if (jqXHR.statusText === "timeout")
{
}
});
azAjaxUrl
Type: String
Default: ""
azAjaxDataType
Type: String
Default: "json"
The type of data you expect back from the server. Other options:
"jsonp" -
"xml" -
"script" -
"html"
azAjaxType
Type: String
Default: "POST"
Other options:
"GET" -
"PUT" -
"DELETE" -
"POST"
azAjaxContentType
Type: String eller Boolean
Default: "application/json; charset=utf-8"
The data type you are sending to the server. See also
azAjaxObjToSend
azAjaxObjHeaders
Type: Object
Default: {}
azAjaxTimeout
Type: Integer
Default: 15000
Unit: milliseconds
azAjaxObjToSend
Type: Object
Default: {}
The data you send is automatically converted into a string -
JSON.stringify(azAjaxObjToSend)