[JQM]Abort pending AJAX request when clicking on link

Hello, I'm building an application with Rhomobile which having a page listing all items in my app. This page use JQM $.ajax function and could take a little bit long to load.

The problem is when user click on the Back link on the header while loading items, the application don't change page immediately but instead showing a loading page widget and waiting until the current pending request complete.

My question is could I make some config to JQM to make it abort all pending request when user click on some link to change page?

I know I could add a listener on click event of the link, but because there're so many links and pages in my app so that require me to add pretty much code. I just want to know a default way to do that.

UPDATE: I find out I could abort the pending AJAX requests in the pagebeforechange event handler. However, because I'm using synchronous call (AsyncHttp without callback) with JQM AJAX, the request is not canceled until my AsyncHttp request complete. I tried to make another call to controller to execute "Rho::AsyncHttp.cancel", but this call still wait for the current synchronous call finish. I know there is a JS API to do "Rho.AsyncHttp.cancel()", but this API can only use with RhoElement license.

Do you know any workaround for this problem?

Thank you very much.

Kutir Mobility
Your best option is to make

Your best option is to make your calls asynchronous.

Synchronous calls will block your interface, so you are forced to wait until the request is complete or it times out.



Kutir Mobility

Vote up!
Vote down!

Points: 0

You voted ‘up’

Log in to post comments