Skip to content

Commit

Permalink
Admin: For IMAP AJAX request, add timeout of 0.5 seconds.
Browse files Browse the repository at this point in the history
Previously, commit 2b54149 didn't add a timeout, so the AJAX request would
hang forever.  Since we do not need to wait for a response, this commit
adds a timeout to stop the AJAX request from continuing.

See #40.
  • Loading branch information
r-a-y committed Mar 9, 2017
1 parent 2b54149 commit 8eb53f5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions includes/bp-rbe-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,24 @@ public function footer() {
$( '.bp-rbe-username span' ).toggle();
});

// Run inbox check.
$('button.connect').on('click', function(e) {
var btn = $(this);
btn.prop( 'disabled', true );
$('.imap-options .spinner').show();
$('.error-rbe').remove();

$.post( ajaxurl, {
action: 'bp_rbe_admin_connect',
'_wpnonce': $('#bp-rbe-ajax-connect-nonce').val()
},
function(response) {

});
// Ping inbox check.
$.post( {
url: ajaxurl,
data: {
action: 'bp_rbe_admin_connect',
'_wpnonce': $('#bp-rbe-ajax-connect-nonce').val()
},
timeout: 500
} );

// Run another AJAX to check if connected.
// Run another AJAX to check if connected after five seconds.
setTimeout( function() {
$.post( ajaxurl, {
action: 'bp_rbe_admin_connect_notice',
Expand Down

0 comments on commit 8eb53f5

Please sign in to comment.