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

View File

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