Skip to content

Instantly share code, notes, and snippets.

@bernardo-cs
Created February 27, 2016 01:06
Show Gist options
  • Save bernardo-cs/70f0ee3e796e902cd7d2 to your computer and use it in GitHub Desktop.
Save bernardo-cs/70f0ee3e796e902cd7d2 to your computer and use it in GitHub Desktop.
var xhr_request = function (post_url, xsrf_token, ids, start_interval, end_interval, callback){
var request = { page_ids: ids, start: start_interval, end: end_interval};
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", callback);
oReq.open("POST", post_url);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.setRequestHeader("X-CSRF-Token", xsrf_token);
oReq.send(JSON.stringify(request));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment