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.
Example
....
typeof gamejs.load('userdata/') === 'object'
typeof gamejs.get('userdata/') === 'string'
...
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.
(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 |
Make http GET request to server-side
Load an object from the server-side.
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 |
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 |