From 8fcb23d7b2a9140d3b83e17bec9c897777c943ba Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 4 Sep 2011 22:49:45 -0700 Subject: [PATCH] $.xhr -> $.ajax --- 4chan_x.user.js | 11 +++++++---- script.coffee | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 40fd2c217..a3f99e9ee 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -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 = { diff --git a/script.coffee b/script.coffee index 2a3b22831..28a836d9c 100644 --- a/script.coffee +++ b/script.coffee @@ -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: ->