Merge branch 'master' into bram1028-patch-1

This commit is contained in:
Maxime Thirouin
2017-12-19 13:50:13 +01:00
committed by GitHub
12 changed files with 240 additions and 27 deletions

View File

@@ -1,4 +1,7 @@
module.exports = function(location, callback) {
module.exports = function(location, options, callback) {
options = options || {};
var requestMethod = options.requestMethod || "GET";
var requestPayload = options.requestPayloadString || null;
var request = new XMLHttpRequest()
request.onreadystatechange = function() {
@@ -17,9 +20,17 @@ module.exports = function(location, callback) {
location += (!/[?&]/.test(location) ? "?" : "&") + new Date().getTime()
}
request.open("GET", location, true)
request.open(requestMethod.toUpperCase(), location, true)
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
request.setRequestHeader("X-PJAX", "true")
request.send(null)
// Add the request payload if available
if (options.requestPayloadString != undefined && options.requestPayloadString != "") {
// Send the proper header information along with the request
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
}
request.send(requestPayload)
return request
}