tags:

views:

68

answers:

3

Sometimes it seems that a request is frozen. How can I cancel it and call it again when it takes a long time?

Sometimes the latency is more than 10 minutes because the Ajax post checks the Twitter API, and Twitter API sometimes, you know! :)

+1  A: 

You can use the timeout option. Have a look at the documentation.

You can set the timeout at a reasonable value. If a timeout occurs, the callback error will be called and the second argument will have "timeout" as value.

kgiannakakis
+1  A: 

Use the timeout option:

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

thedz
A: 

you can always place that call in a timeout or a queue and perform it ever x minutes... when it's thr, set a boolean variable to true and when that time comes, it will not call the function... when you need to call that again, set it again to false...

var getResults = true;


settimeout( function() {
    if( getResults ) {
       // call your ajax method
       ...
       onSuccess: 
          ...
          getResults = false;
    }
}, 1000 );

something like this...

balexandre
setTimeout is for calling a function after a specific *delay*. It does not provide a mechanism to time-out a running function call.
Tomalak