Selaa lähdekoodia

Adds constant for statuses in external_connection.js

dev1
hristoterezov 9 vuotta sitten
vanhempi
commit
f6e0110636
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4
    2
      connection_optimization/external_connect.js

+ 4
- 2
connection_optimization/external_connect.js Näytä tiedosto

@@ -27,11 +27,13 @@ function createConnectionExternally(webserviceUrl, success_callback,
27 27
         return;
28 28
     }
29 29
 
30
+    var HTTP_STATUS_OK = 200;
31
+
30 32
     var xhttp = new XMLHttpRequest();
31 33
 
32 34
     xhttp.onreadystatechange = function() {
33
-        if (xhttp.readyState == 4) {
34
-            if (xhttp.status == 200) {
35
+        if (xhttp.readyState == xhttp.DONE) {
36
+            if (xhttp.status == HTTP_STATUS_OK) {
35 37
                 try {
36 38
                     var data = JSON.parse(xhttp.responseText);
37 39
                     success_callback(data);

Loading…
Peruuta
Tallenna