Browse files

job.js: Add error handler to hide indicator and schedule next update …

…if ajax failed.

- job.js
 * Adding error handler to hide indicator and schedule next update if ajax failed.
   Using .complete() to avoid code duplication between .fail() and .done().

- Issues:
 * fixes #182
  • Loading branch information...
1 parent 1621910 commit 86cb636d605cb0bcbfbd044119a06f067827709f @Krinkle Krinkle committed May 24, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −0 HISTORY.md
  2. +5 −1 js/job.js
View
1 HISTORY.md
@@ -87,6 +87,7 @@ Complete list of issues solved in the 1.0.0 milestone:
query for the users table failed and the username remains unregistered.
* (#162) JobPage with no "new" runs but some "in progress" should still ajax refresh.
* (#166) natsort user agents in UserAction.
+* (#182) JobPage AJAX needs error handler to fix infinite "Updating..".
### Other changes
View
6 js/job.js
@@ -18,14 +18,18 @@ jQuery(function ( $ ) {
}
if ( $( "table.swarm-results" ).find( "td.swarm-status-new, td.swarm-status-progress" ).length ) {
$indicator.stop(true, true).css( "opacity", 1 );
- $.get( window.location.href, function ( html ) {
+ $.get( window.location.href )
+ .done( function ( html ) {
var tableHtml, $targetTable;
tableHtml = $( html ).find( "table.swarm-results" ).html();
$targetTable = $( "table.swarm-results" );
if ( tableHtml !== $targetTable.html() ) {
$targetTable.html( tableHtml );
}
+ })
+ .complete( function () {
+ // Wether done or failed: Clean up and schedule next update
setTimeout( function () {
$indicator.stop(true, true).animate({opacity: 0});
}, 10 );

0 comments on commit 86cb636

Please sign in to comment.