javascript - jQuery Ajax, prevent the refresh button when the ajax is in progress -


hi have perform perform like, when ajax in progress, not allow user page refresh.

here code have

$('#submit').click(function() {         $(function() {         $(".col1").mask("generating csv...."); //this generate mark, here prevent user doing sort of operation.         var = $('#filters_date_to').val();         var = $('#filters_date_from').val();         $.ajax({             url:"../dailytrade/createcsv?filters[date][to]="+to+"&filters[date][from]="+from,success:function(result){                 if(result) {                      $(".col1").unmask(); //here can unlock user using refresh button.                      window.location = '../dailytrade/forcedownload?file='+result;                       settimeout('location.reload(true);',5000);                 }             }             });          });    }); 

any suggestions.

i doubt if should that.

$(window).bind('beforeunload',function(){     return 'are sure want leave?';     }); 

if talking refresh "html button" on web page, can done. before make ajax call, disable refresh button , on success/error function of ajax call enable it.

disable button

$("#refreshbtn").attr("disabled", "disabled"); 

enable button

$("#refreshbtn").removeattr("disabled"); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -