Communication
This class is responsible for server communication using http requests
Constructor Summary
Public Constructor | ||
public |
constructor(form: FormData) Creates an instance of Communication |
Member Summary
Public Members | ||
public get |
form: FormData: * Returns the FormData object attached to the request. |
Method Summary
Public Methods | ||
public |
cancel() Abort a request |
|
public |
Clears all the set headers |
|
public |
deleteHeader(name: String) Delete a header by key |
|
public |
Initiate a GET request |
|
public |
Gets a header by key |
|
public |
getHeaders(): Object Returns an object containing all the headers sets |
|
public |
Sets a listener to track the progress of the request |
|
public |
Parse a url to the correct format |
|
public |
Initiate a POST request |
|
public |
Initiate the request |
|
public |
Sets a header to the request |
Public Constructors
public constructor(form: FormData) source
Creates an instance of Communication
Params:
Name | Type | Attribute | Description |
form | FormData |
|
An existing form that would be sent |
Public Members
public get form: FormData: * source
Returns the FormData object attached to the request. This makes it easier to control the fields.
Return:
FormData | FormData attached to the request |
Public Methods
public deleteHeader(name: String) source
Delete a header by key
Params:
Name | Type | Attribute | Description |
name | String | Header name |
public get(url: String) source
Initiate a GET request
Params:
Name | Type | Attribute | Description |
url | String | The url to request to |
public getHeader(name: String): String source
Gets a header by key
Params:
Name | Type | Attribute | Description |
name | String | Header name |
public listener(progress: Function, end: Function) source
Sets a listener to track the progress of the request
Params:
Name | Type | Attribute | Description |
progress | Function |
|
This function has two parameters, one parameter represents the progress value and the second is the event for onprogress |
end | Function | This function has three parameters, one parameter is the error and one which contains the responseText, and the third one will contain the entire event of onloadend |
public parseUrl(url: String): * source
Parse a url to the correct format
Params:
Name | Type | Attribute | Description |
url | String | The url to request to |
Return:
* |
public post(url: String) source
Initiate a POST request
Params:
Name | Type | Attribute | Description |
url | String | The url to request to |