1 | import isJson from "is-json"
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function 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 |
|
27 | export default ajaxCompleteNative |
\ | No newline at end of file |