Welcome to WebmasterWorld Guest from 184.72.177.182

Forum Moderators: open

Message Too Old, No Replies

Do i need $.ajax async:false if using success: callback function?

     
9:01 pm on Jun 6, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


Hi all,

I was looking over my code and noticed that i had jquery .ajax methods that had the async:false setting in a few javascripts.

So i looked it up on the jQuery site and it said that As of jQuery 1.8, the use of async: false is deprecated. Why would it be depreciated?

I'm not sure i even need async:false, doesn't using a callback function as the success setting value negate the use of async:false?

thanks,
6:10 am on June 8, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


Provided the code following the ajax call does not rely on the completion of the ajax, the async:false can be removed, such code should be in the callback.
12:07 pm on June 8, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


what's the idea behind async:false being depreciated anyway?
1:53 pm on June 8, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts: 4966
votes: 10

1:57 pm on June 8, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Apr 30, 2007
posts:1394
votes: 0


It's because synchronous requests can lock up the ajax state and browser. IMO it should been like this from the beginning and have the code serialize the ajax requests if necessary.
3:53 pm on June 8, 2012 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


ok, thanks....

I changed all my scripts to remove the potential problem and every thing still works.