From d6aa2ef83ea47c3ec7e9f2bd82ee8ae14ce652ea Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 10 Jun 2012 15:45:22 -0700 Subject: [PATCH] ajax: form -> data https://developer.mozilla.org/en/DOM/XMLHttpRequest#send() formdata is just one type of data that can be sent --- 4chan_x.user.js | 18 +++++++++--------- script.coffee | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6563f2c59..7a1ec8f3e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -311,11 +311,11 @@ return d.getElementById(id); }, ajax: function(url, callbacks, opts) { - var form, headers, key, r, type, upCallbacks, val; + var data, headers, key, r, type, upCallbacks, val; if (opts == null) { opts = {}; } - type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form; + type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, data = opts.data; r = new XMLHttpRequest(); r.open(type || 'get', url, true); for (key in headers) { @@ -324,10 +324,10 @@ } $.extend(r, callbacks); $.extend(r.upload, upCallbacks); - if (typeof form === 'string') { - r.sendAsBinary(form); + if (typeof data === 'string') { + r.sendAsBinary(data); } else { - r.send(form); + r.send(data); } return r; }, @@ -1975,7 +1975,7 @@ return QR.el.dispatchEvent(e); }, submit: function(e) { - var callbacks, captcha, captchas, challenge, err, form, m, name, opts, post, reply, response, threadID, val; + var callbacks, captcha, captchas, challenge, data, err, m, name, opts, post, reply, response, threadID, val; if (e != null) { e.preventDefault(); } @@ -2042,11 +2042,11 @@ recaptcha_challenge_field: challenge, recaptcha_response_field: response + ' ' }; - form = new FormData(); + data = new FormData(); for (name in post) { val = post[name]; if (val) { - form.append(name, val); + data.append(name, val); } } callbacks = { @@ -2063,7 +2063,7 @@ } }; opts = { - form: form, + data: data, type: 'POST', upCallbacks: { onload: function() { diff --git a/script.coffee b/script.coffee index c40a271f3..eae2559a5 100644 --- a/script.coffee +++ b/script.coffee @@ -266,14 +266,14 @@ $.extend $, id: (id) -> d.getElementById id ajax: (url, callbacks, opts={}) -> - {type, headers, upCallbacks, form} = opts + {type, headers, upCallbacks, data} = opts r = new XMLHttpRequest() r.open type or 'get', url, true for key, val of headers r.setRequestHeader key, val $.extend r, callbacks $.extend r.upload, upCallbacks - if typeof form is 'string' then r.sendAsBinary form else r.send form + if typeof data is 'string' then r.sendAsBinary data else r.send data r cache: (url, cb) -> if req = $.cache.requests[url] @@ -1546,9 +1546,9 @@ QR = recaptcha_challenge_field: challenge recaptcha_response_field: response + ' ' - form = new FormData() + data = new FormData() for name, val of post - form.append name, val if val + data.append name, val if val callbacks = onload: -> @@ -1562,7 +1562,7 @@ QR = target: '_blank' textContent: 'Connection error, or you are banned.' opts = - form: form + data: data type: 'POST' upCallbacks: onload: ->