new ajax(url, data [, method] [, async])
Ajax method
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
url |
String | The Url to request resource |
||
data |
Object | Parameters to submit |
||
method |
String |
<optional> |
"GET" | Ajax method |
async |
Boolean |
<optional> |
true | Indicate that the request is asynchronous |
Returns:
promise - Promise of asynchronous data
- Type
- html.Promise
Methods
-
<static> clearMock(url)
-
Clear mock data that have been registered
Parameters:
Name Type Description url
String | Array.<String> | undefined -
-
<static> mock(url, data)
-
Mock ajax request
Parameters:
Name Type Description url
String Url string to mock
data
Object Data that we expect to return
-
authenticate(user, pass)
-
Authenticate request with username and password
Parameters:
Name Type Description user
String Username
pass
String Password
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax
-
contentType(miliseconds)
-
Set content type of ajax request
Parameters:
Name Type Description miliseconds
Number Milisecond that timeout event occurs
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax
-
header(key, arg)
-
Set header for a request Extend the header object instead of replace it
Parameters:
Name Type Description key
String | Object Key of header, or an object that contains key value pairs of header
arg
String Value of header
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax
-
jsonp(callback)
-
Set JSONP callback - cross domain purpose
Parameters:
Name Type Description callback
function Callback event handler for JsonP
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax
-
parser(p)
-
Set parser to ajax request
Parameters:
Name Type Description p
function Parser function
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax
-
timeout(miliseconds)
-
Set timeout to ajax request
Parameters:
Name Type Description miliseconds
Number Milisecond that timeout event occurs
Returns:
ajax - Return the ajax itself for fluent API
- Type
- html.ajax