Hi Riccardo, i've a problem in the example you posted you do:
$.jsonp({ url: 'http://api.flickr.com/services/feeds/photos_public.gne? tags=hackdayindia&lang=en-us&format=json&callback=jsonFlickrFeed', timeout: 1, onTimeout: function(url){ console.error('jsonp script timed out: '+url) } }); how about the success function? and the error one etc etc ?!?! I'm tring to something like this : .jsonp({ type: "GET", url: "some.php", data: "name=John&location=Boston", timeout: 1, // in seconds success: function(msg){ alert( "Data Saved: " + msg ); }, error:function(request, errorType, errorThrown){ alert("opppsssss .... "); }, onTimeout:function(url){ console.error('jsonp script timed out: '+url) } }); the success function is never executed (timeout or not). In your example you've defined a function before the $.jsonp call (the jsonFlickrFeed) and added in the url of the request ... why the success function is not working? I've forgotten something? Thanks. On 28 Gen, 10:15, Stefano Corallo <stefan...@gmail.com> wrote: > Ok perfect :) Many thanks. > > So if i've understand the request continue loading and when server > send back the response (if any) if the timeout as occured there is no > callback set on "window" and do nothing else do the job .... have any > sense try to shutdown the request? Is possible? > > Anyway thanks a lot. > > On 28 Gen, 09:23, Stefano Corallo <stefan...@gmail.com> wrote: > > > thank's i'll give it a try ... stay tuned :D > > > On 27 Gen, 22:45, Ricardo Tomasi <ricardob...@gmail.com> wrote: > > > > Hi Stefano, I think I found a solution. All you need to do is check if > > > the callback has been called after your specified timeout. If it has > > > not been called yet, overwrite it with an empty function, else do > > > nothing. That will mess up with any further usage of the callback, but > > > it works for this case anyway, take a look: > > > >http://jsbin.com/ukehu/http://jsbin.com/ukehu/edit > > > > Change the timeout: 1 in the $.jsonp() call to a short/long value to > > > test it. I made the callback and timeout callback Firebug logs also. > > > > cheers, > > > - ricardo > > > > On Jan 27, 5:01 pm, Ricardo Tomasi <ricardob...@gmail.com> wrote: > > > > > Unless you remove the script tag after the 'timeout', of couse. > > > > > On Jan 27, 9:59 am, Mike Alsup <mal...@gmail.com> wrote: > > > > > > > ah .... and there is no way to simulate that? > > > > > > You can simulate a timeout in your code by using setTimeout, but it's > > > > > not the same as when the XHR is used for the request. With XHR jQuery > > > > > can invoke the abort fn to cancel the request. There is no such > > > > > option for the jsonp script injection method. So you can not close > > > > > the connection or do anything particularly useful other than assume > > > > > your timeout is being called because the request failed. But then > > > > > you're only guessing, and the response may return the moment after you > > > > > time it out.