3

I am firing an Ajax request using jQuery. During the process, I show a loading text to the user till it reaches the success/errorhandler function. Is there a way to abort the request in middle of it. So that it doesn't goes to the success/errorHandler variable. One way I can think of is using a global variable. Is there a better method.

Thanks

Svish
  • 152,914
  • 173
  • 462
  • 620
Rakesh
  • 5,793
  • 8
  • 36
  • 37

2 Answers2

4

Perhaps is a start?

$.ajax() returns the XMLHttpRequest that it creates. In most cases you won't need that object to manipulate directly, but it is available if you need to abort the request manually.

http://docs.jquery.com/Ajax/jQuery.ajax#options

Natrium
  • 30,772
  • 17
  • 59
  • 73
0

I think you can just call the abort() method of your request object.

It may be more complicated than this depending on the behaviour you are after see here.

Jeremy French
  • 11,707
  • 6
  • 46
  • 71