detects when server sends a bad formed html page
authorarno <arenevier@fdn.fr>
Thu, 20 Aug 2009 12:54:01 +0000 (14:54 +0200)
committerarno <arenevier@fdn.fr>
Thu, 20 Aug 2009 12:55:18 +0000 (14:55 +0200)
js/admin.js

index e1dfe5f7f04562be72a470b5ea1903beb74959c5..85a28ddca09ee94712d9ba3e547bd01a6745a30f 100644 (file)
@@ -473,6 +473,11 @@ var FeatureMgr = {
         }
 
         var xml = new OpenLayers.Format.XML().read(data);
+        if (!xml.documentElement) {
+            this.commError(SypStrings.UnconsistentError);
+            $("title").focus();
+            return;
+        }
 
         switch (xml.documentElement.nodeName.toLowerCase()) {
             case "error":
@@ -723,7 +728,15 @@ var pwdMgr = {
             }, 0);
             return;
         }
+
         var xml = new OpenLayers.Format.XML().read(data);
+        if (!xml.documentElement) {
+            this.commError(SypStrings.UnconsistentError);
+            $("#login_error").show();
+            window.setTimeout(function() {
+                    $("#user").focus().select();
+            }, 0);
+        }
 
         switch (xml.documentElement.nodeName.toLowerCase()) {
             case "error":
@@ -1024,10 +1037,20 @@ var userMgr = {
             return;
         }
 
+        var xml = new OpenLayers.Format.XML().read(data);
+        if (!xml.documentElement) {
+            // here, we need a timeout because onsend timeout sometimes has not been triggered yet
+            var self = this;
+            window.setTimeout(function() {
+                self.enableForms();
+             }, 0);
+            this.commError(SypStrings.UnconsistentError);
+            return;
+        }
+
         var needFormEnabling = true;
         var focusEl = null;
 
-        var xml = new OpenLayers.Format.XML().read(data);
         switch (xml.documentElement.nodeName.toLowerCase()) {
             case "error":
                 switch (xml.documentElement.getAttribute("reason")) {