save timeout
[redakcja.git] / redakcja / static / js / wiki / wikiapi.js
index 27ab97e..26732bd 100644 (file)
                        type: "POST",
                        dataType: "json",
                        data: data,
+                       timeout: 5000,
                        success: function(data) {
                                var changed = false;
 
 
                                params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
                        },
-                       error: function(xhr) {
-                               try {
-                                       params['failure'](self, $.parseJSON(xhr.responseText));
-                               }
-                               catch (e) {
+                       error: function(xhr, msg) {
+                               if (msg == 'timeout') {
                                        params['failure'](self, {
-                                               "__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
-                                       });
-                               };
-
+                        "__message": "Przekroczony czas połączenia. Zmiany nie zostały zapisane."
+                    });
+                               }
+                               else {
+                    try {
+                        params['failure'](self, $.parseJSON(xhr.responseText));
+                    }
+                    catch (e) {
+                        params['failure'](self, {
+                            "__message": "Nie udało się zapisać - błąd serwera."
+                        });
+                    };
+                               }
                        }
                });
        }; /* end of save() */