supports arraybuffer requests

This commit is contained in:
javi 2014-03-21 12:48:47 +01:00
parent 7e86d58c61
commit fc09a86e51

View File

@ -42,7 +42,8 @@
function get(url, callback, options) {
options = options || {
method: 'GET',
data: null
data: null,
responseType: 'text'
};
lastCall = { url: url, callback: callback };
var request = XMLHttpRequest;
@ -57,7 +58,8 @@
function respond() {
var status = req.status, result;
if (!status && req.responseText || status >= 200 && status < 300 || status === 304) {
var r = options.responseType === 'arraybuffer' ? req.response: req.responseText;
if (!status && r || status >= 200 && status < 300 || status === 304) {
callback(req);
} else {
callback(null);
@ -70,7 +72,7 @@
req.onprogress = function() {};
//req.responseType = 'arraybuffer';
req.responseType = options.responseType; //'arraybuffer';
if (options.data) {
req.setRequestHeader("Content-type", "application/json");
//req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")