]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
XHR alerts for server-side errors: 404, 502, 503, 504. There is also a
authorSarven Capadisli <csarven@controlyourself.ca>
Thu, 23 Apr 2009 21:35:21 +0000 (21:35 +0000)
committerSarven Capadisli <csarven@controlyourself.ca>
Thu, 23 Apr 2009 21:35:21 +0000 (21:35 +0000)
7 second timeout if the server doesn't get back with a response.

js/util.js

index 13036f7caffc1d1129ed35de0ef6c5844853cdbf..c7b1272c8d4b73722d35f9689303e60c03af38f6 100644 (file)
@@ -166,6 +166,25 @@ $(document).ready(function(){
                                                                                                                                                   $("#notice_action-submit").addClass("disabled");
                                                                                                                                                   return true;
                                                                                                                                                 },
+                                          timeout: 1000,
+                                          error: function (xhr, textStatus, errorThrown) {     $("#form_notice").removeClass("processing");
+                                                                                                                                               $("#notice_action-submit").removeAttr("disabled");
+                                                                                                                                               $("#notice_action-submit").removeClass("disabled");
+
+                                                                                                                                               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 {
+                                                                                                                                                       switch(xhr.status) {
+                                                                                                                                                               default: case 404:
+                                                                                                                                                                       alert("Sorry! We had trouble sending your notice.  Please report the problem to the site administrator if this happens again.");
+                                                                                                                                                                       break;
+                                                                                                                                                               case 502: case 503: case 504:
+                                                                                                                                                                       alert("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.");
+                                                                                                                                                                       break;
+                                                                                                                                                       }
+                                                                                                                                               }
+                                                                                                                                         },
                                           success: function(xml) {     if ($("#error", xml).length > 0) {
                                                                                                        var result = document._importNode($("p", xml).get(0), true);
                                                                                                        result = result.textContent || result.innerHTML;