|
|
|
@ -12,6 +12,29 @@ |
|
|
|
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
|
|
|
xhr.send(""); |
|
|
|
|
} |
|
|
|
|
function makeRequest(method, url, payload) { |
|
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
|
let xhr = new XMLHttpRequest(); |
|
|
|
|
xhr.open(method, url); |
|
|
|
|
xhr.onload = function () { |
|
|
|
|
if (this.status >= 200 && this.status < 300) { |
|
|
|
|
resolve(xhr.response); |
|
|
|
|
} else { |
|
|
|
|
reject({ |
|
|
|
|
status: this.status, |
|
|
|
|
statusText: xhr.statusText |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
xhr.onerror = function () { |
|
|
|
|
reject({ |
|
|
|
|
status: this.status, |
|
|
|
|
statusText: xhr.statusText |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
!payload ? xhr.send() : xhr.send(payload); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
{% block head %} |
|
|
|
|
{% endblock %} |
|
|
|
|