GM AJAX
About

GM AJAX is an extension for GameMaker:HTML5 which allows for simple AJAX (Asynchronous JavaScript and XML) communication.

Functions

ajax_request_new()
Creates a new AJAX request and returns the ID.

ajax_request_send(id,method,url,data)
Sends the AJAX request with the specified ID. Method specifies whether it is a "GET" or "POST" request. URL indicates the file to request. Data is a string containing any information to be submitted with the request.

ajax_check_reply(id)
Checks to see if a reply is ready for the specified AJAX request. Returns true if a reply is ready, returns false if not.

ajax_check_failed(id)
Checks to see if the specified AJAX request has failed. Returns true if the AJAX request has failed. Returns false if it has not yet failed. (Example: If the specified URL returns a 404 Not Found Error)

ajax_read_reply(id)
Returns the reply received for the specified AJAX request.

ajax_clear_requests()
Clears all AJAX requests and resets ID assigning. This frees memory, which is particularly useful if your application sends a large number of AJAX requests over time. (Warning: This function clears all AJAX requests and IDs, regardless of whether they have been sent or replied to. Use caution if you have variables holding old ID numbers, as newly created requests will begin using old ID numbers.)

Limitations

GM AJAX is bound by the Same Origin Policy, meaning cross domain AJAX requests are not permitted unless the server allows cross-origin resource sharing (I.e. AJAX requests can only be sent to pages hosted on the same domain as your HTML5 application).

In some instances, the response from AJAX GET requests will be cached by the user's browser. If caching is not desired, the server response must include a 'no-cache' header. Alternatively, use a POST request if caching is not desired.

License

GM AJAX is licensed under a Creative Commons Attribution 3.0 Unported License.

(You are free to use, modify and distribute this work, including for commerical purposes.)

GM AJAX Created by JacksonYarr