How to cancel the download or change the page for jQuery mobile?

I want to cancel the cancellation of the download or change the page on the beforecreate page for jQuery mobile. what function jquery mobile can do this?

+4
source share
3 answers

If possible for a specific use case, consider using the pagechange event instead of pagebeforecreate . You can prevent the ajax request in the first place, rather than using the abort() ajax request method. The code will look like this:

 $(document).bind("pagebeforechange", function(e, data) { // check data.toPage attribute here and decide if the pagechange should be canceled e.preventDefault(); }); 
+2
source

abort () method can help you. Here is a similar question: Stop all active ajax requests in jQuery

Basically, just assign the request to varaible (somevar) and call somevar.abort () to kill the ajax command before it finishes processing.

+1
source

It works great for me.

 $.mobile.changePage( "../alerts/confirm.html", { transition: "pop", reverse: false, }); 
0
source

All Articles