2009/7/21 András Csányi <sayusi.a...@gmail.com>:
>
> Okay. You are right and the options what you mentioned likes form me,
> but I asked hungarian web developers and they sad I have a third
> option:
> using ajaxSetup llike this:
> $.ajaxSetup({
>  async: false
> });
> The problem what I see in this case that ajaxSetup working globally
> and after async calls I have to set back to sync.

Disabling async is a terrible idea. Disabling it because of a slow
server is even worse. It will cause the browser to freeze until the
result comes back from the server. It guarantees a terrible user
experience.

You can achieve what you want by storing a reference to the callback
function in a variable, then changing that variable to hold a
reference to a different function when the appropriate conditions are
satisfied. I have an example at
<http://www.nickfitz.co.uk/examples/javascript/switching-functions.html>
although it's pure JavaScript, not jQuery; the code is all in the page
(not what I'd usually do, except for examples like this) so you can
view the source to see what it's doing.

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/

Reply via email to