forked from x/volcanos
add some
This commit is contained in:
parent
a2546c5fac
commit
57d741653a
10
lib/misc.js
10
lib/misc.js
@ -92,9 +92,15 @@ Volcanos("misc", {
|
|||||||
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")
|
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")
|
||||||
if (can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" }
|
if (can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" }
|
||||||
xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
|
xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
|
||||||
try { var res = JSON.parse(xhr.responseText) } catch (e) { var res = {result: [xhr.responseText]} } msg.Option("_cost", new Date() - begin)
|
try { var res = JSON.parse(xhr.responseText) } catch (e) {
|
||||||
|
if (xhr.responseText.indexOf("warn: ")) {
|
||||||
|
var res = {result: [xhr.responseText]}
|
||||||
|
} else {
|
||||||
|
var res = {result: [xhr.responseText]}
|
||||||
|
}
|
||||||
|
} msg.Option("_cost", new Date() - begin)
|
||||||
if (xhr.status == 200) { return msg.detail || (msg.detail = res.detail), can.base.isFunc(cb) && cb(msg.Copy(res)) }
|
if (xhr.status == 200) { return msg.detail || (msg.detail = res.detail), can.base.isFunc(cb) && cb(msg.Copy(res)) }
|
||||||
can.user.toastFailure(can, xhr.response, url), can.misc.Warn(xhr.status, res, url, form)
|
can.user.toastFailure(msg._can||can, xhr.response), can.misc.Warn(xhr.status, res, url, form)
|
||||||
cbs && cbs(xhr)
|
cbs && cbs(xhr)
|
||||||
}, xhr.setRequestHeader(http.Accept, msg._accept||http.ApplicationJSON)
|
}, xhr.setRequestHeader(http.Accept, msg._accept||http.ApplicationJSON)
|
||||||
if (msg._upload) { var data = new FormData(); can.core.ItemForm(form, function(v, i, k) { data.append(k, v) })
|
if (msg._upload) { var data = new FormData(); can.core.ItemForm(form, function(v, i, k) { data.append(k, v) })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user