smarter ajax type checking
This commit is contained in:
parent
d6aa2ef83e
commit
f7a9fb526e
@ -317,7 +317,11 @@
|
|||||||
}
|
}
|
||||||
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();
|
||||||
r.open(type || 'get', url, true);
|
if (data) {
|
||||||
|
type || (type = 'post');
|
||||||
|
}
|
||||||
|
type || (type = 'get');
|
||||||
|
r.open(type, url, true);
|
||||||
for (key in headers) {
|
for (key in headers) {
|
||||||
val = headers[key];
|
val = headers[key];
|
||||||
r.setRequestHeader(key, val);
|
r.setRequestHeader(key, val);
|
||||||
@ -2064,7 +2068,6 @@
|
|||||||
};
|
};
|
||||||
opts = {
|
opts = {
|
||||||
data: data,
|
data: data,
|
||||||
type: 'POST',
|
|
||||||
upCallbacks: {
|
upCallbacks: {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
return QR.status({
|
return QR.status({
|
||||||
|
|||||||
@ -268,7 +268,9 @@ $.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()
|
||||||
r.open type or 'get', url, true
|
type or= 'post' if data
|
||||||
|
type or= 'get'
|
||||||
|
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
|
||||||
@ -1563,7 +1565,6 @@ QR =
|
|||||||
textContent: 'Connection error, or you are banned.'
|
textContent: 'Connection error, or you are banned.'
|
||||||
opts =
|
opts =
|
||||||
data: data
|
data: data
|
||||||
type: 'POST'
|
|
||||||
upCallbacks:
|
upCallbacks:
|
||||||
onload: ->
|
onload: ->
|
||||||
# Upload done, waiting for response.
|
# Upload done, waiting for response.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user