Module gamejs/http

Make synchronous http requests to your game's serverside component.

If you configure a ajax base URL you can make http requests to your server using those functions. The most high-level functions are load() and save() which take and return a JavaScript object, which they will send to / recieve from the server-side in JSON format.

Functions

Class Response

Instance Methods


Response (responseXML, status, statusText)

Response object returned by http functions get and post. This class is not instantiable.

Parameters

String responseXML
Number status
String statusText

Response.prototype.getResponseHeader (header)

Parameters

String header

ajax (method, url, data, type)

Make http request to server-side

Parameters

String method http method
String url
String|Object data
String|Object type "Accept" header value

Returns

Response response

get (url)

Make http GET request to server-side

Parameters

String url

load (url)

Load an object from the server-side.

Parameters

String url

Returns

Object the object loaded from the server

post (url, data, type)

Make http POST request to server-side

Parameters

String url
String|Object data
String|Object type "Accept" header value

Returns

Response

save (url, data, type)

Send an object to a server-side function.

Parameters

String url
String|Object data
String|Object type "Accept" header value

Returns

Object the response object