This commit is contained in:
James Campos 2012-06-12 10:02:32 -07:00
parent e770265266
commit 1e2aa40e22
2 changed files with 4 additions and 12 deletions

View File

@ -330,10 +330,7 @@
} }
type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, data = opts.data; type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, data = opts.data;
r = new XMLHttpRequest(); r = new XMLHttpRequest();
if (data) { type || (type = data && 'post' || 'get');
type || (type = 'post');
}
type || (type = 'get');
r.open(type, url, true); r.open(type, url, true);
for (key in headers) { for (key in headers) {
val = headers[key]; val = headers[key];
@ -341,11 +338,7 @@
} }
$.extend(r, callbacks); $.extend(r, callbacks);
$.extend(r.upload, upCallbacks); $.extend(r.upload, upCallbacks);
if (typeof data === 'string') { r.send(data);
r.sendAsBinary(data);
} else {
r.send(data);
}
return r; return r;
}, },
cache: function(url, cb) { cache: function(url, cb) {

View File

@ -276,14 +276,13 @@ $.extend $,
ajax: (url, callbacks, opts={}) -> ajax: (url, callbacks, opts={}) ->
{type, headers, upCallbacks, data} = opts {type, headers, upCallbacks, data} = opts
r = new XMLHttpRequest() r = new XMLHttpRequest()
type or= 'post' if data type or= data and 'post' or 'get'
type or= 'get'
r.open type, url, true r.open type, url, true
for key, val of headers for key, val of headers
r.setRequestHeader key, val r.setRequestHeader key, val
$.extend r, callbacks $.extend r, callbacks
$.extend r.upload, upCallbacks $.extend r.upload, upCallbacks
if typeof data is 'string' then r.sendAsBinary data else r.send data r.send data
r r
cache: (url, cb) -> cache: (url, cb) ->
if req = $.cache.requests[url] if req = $.cache.requests[url]