looking for some solutions? You are welcome.

SOLVED: How to abort ajax request on page refresh

dheeraj kumar:

I have a form, on submit of that I am making an ajax request which is sometimes taking time to get the request, so what I am trying to do is whenever user refresh or clicks back button of the browser after form submitting i want to abort that ajax call

  • What I am doing is

    $("#formId").submit(function(event) {
       var xhr = $.ajax({
          url : "Drilldown",
          method : "GET",
          success : function(data) {
             //  here doing ,my stuff    
          complete : function() {
      window.onbeforeunload = function() {
         return "some message"; // here when user clicks on leave then want to abort like `xhr.abort`
  • whenever the user clicks on leave I want to abort my ajax request

How can I do that?

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: