just.request(urlnon-null, fnopt, optionsopt) → {*}
Make a request using XMLHttpRequest.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| url | url | Some url. | ||||||||||||||||||||||||||||||||||||||||
| fn [optional] | just.request~fn | Hook for onreadystatechange listener. | ||||||||||||||||||||||||||||||||||||||||
| options [optional] | object | Properties
|
Returns:
The retuned value of just.request~send.
- Type
- Any
Methods
appendData(url, datanullable) → {string}
Append data to the search params of the given url.
Parameters:
| Name | Type | Description |
|---|---|---|
| url | string | Some url. |
| data [nullable] | object | An object to be appended. |
Returns:
- Type
- string
Example
appendData('/some', {'data': 1}); // > '/some?data=1'
appendData('/some?url', {'data': 1}); // > '/some?url&data=1'dataToUrl(datanullable) → {string}
Convert data into search params.
Parameters:
| Name | Type | Description |
|---|---|---|
| data [nullable] | object | Expects an object literal. |
Throws:
If data is not an object.
- Type
- TypeError
Returns:
- Type
- string
Example
dataToUrl({'a': '&a', 'b': 2}); // > 'a=%26&b=2'Type Definitions
defaultHeaders
Default request headers.
Properties:
| Name | Type | Default | Description |
|---|---|---|---|
| X-Requested-With [optional] | string | "XMLHttpRequest" | |
| Content-Type [optional] | string | "application/json" | Only on JSON requests. |
Type:
object
defaultProps
Default request properties.
Properties:
| Name | Type | Default | Description |
|---|---|---|---|
| responseType [optional] | string | "json" | Only on JSON requests. |
Type:
object
fn(errornullable, response)
A function to call on "load"/"error" event.
This:
{XMLHttpRequest}
Parameters:
| Name | Type | Description |
|---|---|---|
| error [nullable] | Error | Bad status error or null. |
| response | Any | Either #response or #responseText property. On JSON request, the property parsed as a JSON. |
