How can I make JQuery.ajax synchronous with a timeout? -
i have calendar data on server. when user moves forward month, might (based on previous actions) need fetch data before can display month.
my code handles failure (404), can't make deal timeout, because call synchronous. know timeout ignored when .ajax call synchronous, want know how make synchronous wait around async call? want deal timeout, short of spin loop, don't know how elegantly in javascript.
i have modal dialog on page stop clicks, need hold user until can render next month, or if timeout happens, prevent them moving month, since data on month isn't valid.
i don't quite see how jquery code pulling off...
i think want keep screen locked out until either success or failure. sounds want make ajax call aysnch , register callback functions jquery ajax (for example, on error event):
error(jqxhr, textstatus, errorthrown)function function called if request fails. function receives 3 arguments: jqxhr (in jquery 1.4.x, xmlhttprequest) object, string describing type of error occurred , optional exception object, if 1 occurred. possible values second argument (besides null) "timeout", "error", "abort", , "parsererror". ajax event. of jquery 1.5, error setting can accept array of functions. each function called in turn. note: handler not called cross-domain script , jsonp requests.
Comments
Post a Comment