Comparing version 1.2.2 to 1.3.3
@@ -18,3 +18,3 @@ var XMLHttpRequest = require('xhrpolyfill'); | ||
var xhr = XMLHttpRequest(); | ||
if (!xhr) { return null }; | ||
if (!xhr) { throw new Error('No AJAX support'); }; | ||
xhr.open(args.method,args.url); | ||
@@ -30,5 +30,7 @@ for (var field in args.headers) { | ||
}); | ||
callback(this.response, response, xhr, headerJSON); | ||
if (callback) { | ||
callback(this.response, response, xhr, headerJSON); | ||
} | ||
}; | ||
xhr.send(args.body||null); | ||
}; |
{ | ||
"name": "minixhr", | ||
"version": "1.2.2", | ||
"version": "1.3.3", | ||
"description": "super simpel and small cross-browser xhr", | ||
@@ -26,4 +26,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"xhrpolyfill": "^1.0.0" | ||
"xhrpolyfill": "^1.3.0" | ||
} | ||
} |
@@ -8,7 +8,17 @@ # minixhr | ||
var request = { url: 'http://github.com/serapath/holonify' }; | ||
var callback = function responseHandler (data, response, xhr, header) { console.log(data); }; | ||
var request = { // can be 'url string' or object: | ||
url : 'http://github.com/serapath/holonify', // or e.g. http://ip.jsontest.com/a=1&b=2&c=3 | ||
method : 'POST', // [optional] (defaults to 'GET') | ||
body : 'payload', // [optional] payload data could be <formdata> or {key:val}'s or anything | ||
header : {} // [optional] (defaults to '{}' or in case of 'POST': | ||
// {'X-Requested-With':'XMLHttpRequest','Content-Type':'application/x-www-form-urlencoded' } ) | ||
}; | ||
minixhr(request, function responseHandler (data, response, xhr, header) { | ||
console.log(data); | ||
}); | ||
// EXAMPLE 1 | ||
minixhr(request); // [optional] callback - (e.g. leave out for POST Request where you don't care about a response | ||
// EXAMPLE 2 | ||
minixhr('http://requestb.in/qpvy9dqp', function (data) { console.log(data); }); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3570
33
24
Updatedxhrpolyfill@^1.3.0