make xhr.abort reject promise chain

This commit is contained in:
Leo Horie 2014-04-29 22:19:07 -04:00
parent c1f6705a59
commit 38dba03f6d
11 changed files with 69 additions and 13 deletions

View file

@ -398,6 +398,9 @@ Mithril = m = new function app(window) {
xhr.open(options.method, options.url, true, options.user, options.password)
xhr.onload = typeof options.onload == "function" ? options.onload : function() {}
xhr.onerror = typeof options.onerror == "function" ? options.onerror : function() {}
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 0) xhr.onerror({type: "error", target: xhr})
}
if (typeof options.config == "function") options.config(xhr, options)
xhr.send(options.data)
return xhr