UNPKG

760 BJavaScriptView Raw
1import isJson from "is-json"
2
3
4/**
5 * This module need further work.
6 * @param callback
7 */
8function ajaxCompleteNative(callback) {
9 XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send
10 XMLHttpRequest.prototype.send = function (body) {
11 this.addEventListener("progress", function () {
12 console.log("Loading")
13 }, false)
14
15 this.addEventListener("load", function () {
16 if (isJson(this.responseText)) {
17 let responseJSON = JSON.parse(this.responseText)
18 console.log("responses", responseJSON)
19 }
20 console.log("xhr", this)
21 console.log("body", body)
22 }, false)
23 this.realSend(body)
24 }
25}
26
27export default ajaxCompleteNative
\No newline at end of file