1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| function get() { var xhr = new XMLHttpRequest(); var url = "请求地址"; xhr.open("POST", url); xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xhr.responseType = "blob"; xhr.addEventListener("loadstart", function (ev) { $("#progress-dialog").modal('show') }); xhr.addEventListener("load", function (ev) { processRequest(xhr); }); xhr.addEventListener("progress", function(ev) { var max = ev.total; var value = ev.loaded; var width = value/max*100; }); xhr.addEventListener("loadend", function(ev) { }); xhr.addEventListener("error", function(ev) { }); xhr.addEventListener("abort", function(ev) { });
xhr.send(JSON.stringify({ })); }
|