@soyjavi vor 14 Jahren
Ursprung
Commit
5cebda1355
1 geänderte Dateien mit 11 neuen und 4 gelöschten Zeilen
  1. 11 4
      src/lib/QuoJS.js

+ 11 - 4
src/lib/QuoJS.js

@@ -666,9 +666,17 @@ window.Quo = Quo;
                 _xhrTimeout(xhr, settings);
             }, settings.timeout);
         }
-        xhr.send(settings.data);
 
-        return (settings.async) ? xhr : _parseResponse(xhr, settings);
+        try {
+            xhr.send(settings.data);
+            if (xhr.status !== 500) {
+                return (settings.async) ? xhr : _parseResponse(xhr, settings);
+            }
+        }
+        catch (error) {
+           xhr = error;
+           _xhrError('Resource not found', xhr, settings);
+        }
     };
 
     /**
@@ -746,7 +754,7 @@ window.Quo = Quo;
     };
 
     function _xhrStatus(xhr, settings) {
-        if (xhr.status === 200) {
+        if (xhr.status === 200 || xhr.status === 0) {
             if (settings.async) {
                 var response = _parseResponse(xhr, settings);
                 _xhrSuccess(response, xhr, settings);
@@ -781,7 +789,6 @@ window.Quo = Quo;
 
     function _parseResponse(xhr, settings) {
         var response = xhr.responseText;
-
         if (response) {
             if (settings.dataType === DEFAULT.MIME) {
                 try {