• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using false in open() for Ajax

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I wanted to know if we can use false in the open() of XMLHttpRequest Object? If yes, then what is the advantage of using it. I think it would behave like a synchronous call(posting the whole form ???)..
Then writing down the Ajax code would be renderd useless. Any code snippet would be highly appreciated.
Please correct me where I am wrong.

Regards,
Roshani
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can, and it would be the same as sending a synchronous request, which means that the client will have to wait until the server finishes. I can't think of any use for this.
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Satou,
It cleared my doubt. But stil i wonder why it was given in the first place altogether, in the open()??? Anybody else please..
Regards,
Roshani
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because people might want to make a synchronous request. Not sure what the question is here.

Eric
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric,
Thanks for replying. I understand that in the open(), specifying "true" means we want to make a asyn call(Ajax call). Giving it to false would imply having syn call. This further implies that script waits for a reponse before continuing the script processing. The client will not be able to post any more data till the response has come back from the server.
So making a sync call is as good doing a postback. So where does the differnce lie in having a postback (Submit button) and writing down the whole code in the JS where it would be just making a sync call???

What could be any scernaio that I might want to use false in the open().

Regards,
Roshani
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer is:
When you do not want to make a sych. request.

I am not sure what you are looking for here. I would not use a sych. request with the XMLHttpRequest onject since it can lock up a browser in certain situations.

Eric
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric,

I understood that using XMLHttpRequest object for sync calls would lock the UI while req is being made. Real life scenarios are very few where we use false in open().

By the way, Ajax in Action is lovely book. Thanks for such a great book.

Regards,
Roshani
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some people want to lock the browser for doing things like a double combo (linked selects).

Something that requires processing before continuing is another example. Again, if I were to do something like that, I would normally do a post back since I would not want to risk browser freezing do to a problem.

Eric
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic