Skip to content

Instantly share code, notes, and snippets.

@jzerbe
Created January 17, 2013 02:59
Show Gist options
  • Save jzerbe/4553151 to your computer and use it in GitHub Desktop.
Save jzerbe/4553151 to your computer and use it in GitHub Desktop.
use a previously initialized CORS XHR object to POST a JSON payload
function postCorsRequest(theUrl, theJsonObj, theOnLoadCallback, theErrorCallback) {
var aJsonStr = JSON.stringify(theJsonObj);
var aRequest = createCorsRequest("post", theUrl);
if (aRequest) {
aRequest.onload = theOnLoadCallback;
aRequest.onerror = theErrorCallback;
aRequest.send(aJsonStr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment