| Author |
synchronous request through Ajax
|
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
When anyone would make a synchronous request though Ajax??? request.open("GET", "some.do", false); Thanks.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
When they want a sychronous Request! Eric
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Originally posted by Eric Pascarello: When they want a sychronous Request! Eric
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
Originally posted by rathi ji: sychronous Request
synchronous request, "the code will hang until a response comes back"
|
Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Originally posted by Saif Uddin: synchronous request, "the code will hang until a response comes back"
Not the code, the browser will hang...
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
yes you are right. can you run javaScript code without using browser? absolutely not hope you understand what the exactly I mean when I use "code" word.
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
|
Well, my question was different and still unanswered. :roll:
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8142
|
|
Well, my question was different and still unanswered
Eric has already answered it for you. Hasn't he?
When they want a sychronous Request!
|
[My Blog] [JavaRanch Journal]
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Originally posted by Jaikiran Pai: [QB][/QB]
Nope. I was expecting 2-3 practical situations where it's good to make synchronous request through Ajax.
|
 |
Frank Zammetti
Ranch Hand
Joined: Dec 16, 2004
Posts: 136
|
|
I would contend there aren't many instances where you'd want to set XMLHttpRequest to synchronous mode... although Eric is of course correct, if your employer says so, do it Failing that though, I think what people *do* more often come up against is not wanting more than one AJAX request processing at a time, which is synchronous in a sense too, but not the same way. In this situation you see things like setting and checking flags before sending a new request, locking out the submit button on the UI, things like that. That tends to come up more often.
|
-- <br />Frank W. Zammetti<br />Founder and Chief Software Architect<br />Omnytex Technologies<br /><a href="http://www.omnytex.com" target="_blank" rel="nofollow">http://www.omnytex.com</a><br />AIM/Yahoo: fzammetti<br />MSN: fzammetti@hotmail.com<br />Author of "Practical Ajax Projects With Java Technology"<br /> (2006, Apress, ISBN 1-59059-695-1)<br />and "JavaScript, DOM Scripting and Ajax Projects"<br /> (2007, Apress, ISBN 1-59059-816-4)<br />Java Web Parts - <a href="http://javawebparts.sourceforge.net" target="_blank" rel="nofollow">http://javawebparts.sourceforge.net</a><br /> Supplying the wheel, so you don't have to reinvent it!
|
 |
Rajan Chinna
Ranch Hand
Joined: Jul 01, 2004
Posts: 320
|
|
Can I say it doesn't make sense to use AJAX in synchronous mode? The whole purpose of Ajax is Async then under which scenario we should set this false parameter?
|
 |
Frank Zammetti
Ranch Hand
Joined: Dec 16, 2004
Posts: 136
|
|
Hi Rajan... I think the cases where it might be desirable to make a synchronous call are when you absolutely have to ensure other code doesn't execute before the response is returned... maybe you have some timer code that can't fire until the response is received. Might make sense then. It's also an easy way, although I'd contend a poor way, to guard against multiple simultaneous AJAX requests, which is sometimes desirable. I agree though, I can't myself think of a case where it really does make more sense than other options, but just because I can't come up with a scenario doesn't mean there aren't any
|
 |
 |
|
|
subject: synchronous request through Ajax
|
|
|