axj-ab_ 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +17 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -562,19 +562,27 @@ var ab_ = {
562
562
  xhrReq: function (loading, headers, url, posts, callback, init) {
563
563
  var xhr = new XMLHttpRequest();
564
564
  var done = XMLHttpRequest.DONE || 4;
565
+ var onDone = function() {
566
+ if(done == -1) return
567
+ done = -1
568
+ onDone = undefined
569
+ loading && loading();
570
+ if (callback) {
571
+ if (xhr.status === 200) {
572
+ callback(null, xhr.responseText, xhr);
573
+ }
574
+ else {
575
+ callback(xhr.text || 'fail', null, xhr);
576
+ }
577
+ }
578
+ }
565
579
  xhr.onreadystatechange = function () {
566
580
  if (xhr.readyState === done) {
567
- loading && loading();
568
- if (callback) {
569
- if (xhr.status === 200) {
570
- callback(null, xhr.responseText);
571
- }
572
- else {
573
- callback(xhr.text || 'fail', null);
574
- }
575
- }
581
+ onDone()
576
582
  }
577
583
  };
584
+ xhr.onloadend = onDone
585
+ xhr.ontimeout = onDone
578
586
  // 设置30s超时时间
579
587
  // xhr.timeout = 30000
580
588
  // xhr.ontimeout = ab_.xhrOntimeout()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "axj-ab_",
3
3
  "type": "commonjs",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {