]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
60 seconds hard timeout for XHR notice posting. JavaScript throws an
authorSarven Capadisli <csarven@controlyourself.ca>
Fri, 1 May 2009 17:00:36 +0000 (17:00 +0000)
committerSarven Capadisli <csarven@controlyourself.ca>
Fri, 1 May 2009 17:00:36 +0000 (17:00 +0000)
alert message to the client if the server doesn't respond back in any
way.

js/util.js

index f15c4f2bbf1e92f94e9f67af17ba247fb277906f..3f14bc61c6d831d35a822c704a637f702b4beda9 100644 (file)
@@ -166,14 +166,20 @@ $(document).ready(function(){
                                                                                                                                                   $("#notice_action-submit").addClass("disabled");
                                                                                                                                                   return true;
                                                                                                                                                 },
+                                          timeout: '60000',
                                           error: function (xhr, textStatus, errorThrown) {     $("#form_notice").removeClass("processing");
                                                                                                                                                $("#notice_action-submit").removeAttr("disabled");
                                                                                                                                                $("#notice_action-submit").removeClass("disabled");
-                                                                                                                                               if ($(".error", xhr.responseXML).length > 0) {
-                                                                                                                                                       $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
+                                                                                                                                               if (textStatus == "timeout") {
+                                                                                                                                                       alert ("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists");
                                                                                                                                                }
                                                                                                                                                else {
-                                                                                                                                                       alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again.");
+                                                                                                                                                       if ($(".error", xhr.responseXML).length > 0) {
+                                                                                                                                                               $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
+                                                                                                                                                       }
+                                                                                                                                                       else {
+                                                                                                                                                               alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again.");
+                                                                                                                                                       }
                                                                                                                                                }
                                                                                                                                          },
                                           success: function(xml) {     if ($("#error", xml).length > 0) {
@@ -189,7 +195,6 @@ $(document).ready(function(){
                                                     }
                                                     else {
                                                          li = $("li", xml).get(0);
-                                                         id = li.id;
                                                          if ($("#"+li.id).length == 0) {
                                                               $("#notices_primary .notices").prepend(document._importNode(li, true));
                                                               $("#notices_primary .notice:first").css({display:"none"});