$.xhr -> $.ajax

This commit is contained in:
James Campos 2011-09-04 22:49:45 -07:00
parent ef086934f1
commit 8fcb23d7b2
2 changed files with 11 additions and 8 deletions

View File

@ -314,11 +314,14 @@
$.add(d.head, script);
return $.rm(script);
},
xhr: function(url, cb) {
ajax: function(url, cb, type) {
var r;
if (type == null) {
type = 'get';
}
r = new XMLHttpRequest();
r.onload = cb;
r.open('get', url, true);
r.open(type, url, true);
r.send();
return r;
},
@ -331,7 +334,7 @@
return req.callbacks.push(cb);
}
} else {
req = $.xhr(url, (function() {
req = $.ajax(url, (function() {
var cb, _i, _len, _ref, _results;
_ref = this.callbacks;
_results = [];
@ -1816,7 +1819,7 @@
}
url = location.pathname + '?' + Date.now();
cb = updater.cb.update;
return updater.request = $.xhr(url, cb);
return updater.request = $.ajax(url, cb);
}
};
watcher = {

View File

@ -219,10 +219,10 @@ $.extend $,
textContent: "(#{code})()"
$.add d.head, script
$.rm script
xhr: (url, cb) ->
ajax: (url, cb, type='get') ->
r = new XMLHttpRequest()
r.onload = cb
r.open 'get', url, true
r.open type, url, true
r.send()
r
cache: (url, cb) ->
@ -232,7 +232,7 @@ $.extend $,
else
req.callbacks.push cb
else
req = $.xhr url, (-> cb.call @ for cb in @callbacks)
req = $.ajax url, (-> cb.call @ for cb in @callbacks)
req.callbacks = [cb]
$.cache.requests[url] = req
cb:
@ -1489,7 +1489,7 @@ updater =
updater.request?.abort()
url = location.pathname + '?' + Date.now() # fool the cache
cb = updater.cb.update
updater.request = $.xhr url, cb
updater.request = $.ajax url, cb
watcher =
init: ->