Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Ajax in sync mode works with IE, does not work with Firefox

Reply
Thread Tools

Ajax in sync mode works with IE, does not work with Firefox

 
 
zalek
Guest
Posts: n/a
 
      08-29-2008
I am writing application with Ajax in sync mode - xmlHttp.open("GET",
url, false).
I noticed that in FireFox handler doesn't starts. It starts when I use
xmlHttp.open("GET", url,true).
I need to use it in sync mode. Any ideas what can I do?

Thanks,

Zalek.
 
Reply With Quote
 
 
 
 
Jorge
Guest
Posts: n/a
 
      08-29-2008
On Aug 29, 3:55*am, zalek <(E-Mail Removed)> wrote:
> I am writing application with Ajax in sync mode - xmlHttp.open("GET",
> url, false).
> I noticed that in FireFox handler doesn't starts. It starts when I use
> xmlHttp.open("GET", url,true).
> I need to use it in sync mode. Any ideas what can I do?
>


The callback won't get called for synchronous XHR requests (there's no
need to).

But (AFAIK) nothing prevents you from calling it ("by hand") if you
need to, inmediatly after the .open(,,false) :

//xmlHttp.onreadystatechange= myCallback;
xmlHttp.open("GET", url, false);
myCallback();

--Jorge.

 
Reply With Quote
 
 
 
 
GArlington
Guest
Posts: n/a
 
      08-29-2008
On Aug 29, 2:55*am, zalek <(E-Mail Removed)> wrote:
> I am writing application with Ajax in sync mode - xmlHttp.open("GET",
> url, false).
> I noticed that in FireFox handler doesn't starts. It starts when I use
> xmlHttp.open("GET", url,true).
> I need to use it in sync mode.

WHY do you need to make AJAX call "in sync mode"? IT will only stop
doing anything else until it gets a response from the server...
So, just DO NOT do anything else until you get a response...
Or maybe I misunderstand what you are trying to do...
> Any ideas what can I do?
>
> Thanks,
>
> Zalek.


 
Reply With Quote
 
optimistx
Guest
Posts: n/a
 
      08-29-2008
zalek wrote:
> I am writing application with Ajax in sync mode - xmlHttp.open("GET",
> url, false).
> I noticed that in FireFox handler doesn't starts. It starts when I use
> xmlHttp.open("GET", url,true).
> I need to use it in sync mode. Any ideas what can I do?
>
> Thanks,
>
> Zalek.

Is this correct:
If the response for any reason does not come immediately but e.g. in 20
seconds (or never!)
the whole browser page is like dead, keyboard dead, mouse clicking has no
effect, the user becomes angry and desperate, goes away from your page and
never comes back. Or ...?


 
Reply With Quote
 
Steve Swift
Guest
Posts: n/a
 
      08-29-2008
GArlington wrote:
> WHY do you need to make AJAX call "in sync mode"?


It's the difference between "while you wait" and "drop it off and we'll
call you when its ready". Many people prefer the "while you wait"
approach. It's certainly simpler. For some processes, it is the only one
that makes sense (for example, going to the dentists).

Let's see how you get on at the next trip to the dentists if they say
"Drop them off and we'll call you when they're ready".

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
 
Reply With Quote
 
Steve Swift
Guest
Posts: n/a
 
      08-29-2008
optimistx wrote:
> If the response for any reason does not come immediately but e.g. in
> 20 seconds (or never!) the whole browser page is like dead, keyboard
> dead, mouse clicking has no effect, the user becomes angry and
> desperate, goes away from your page and never comes back. Or ...?


I'm writing a webpage where I'll be updating our database on every
change of the checkboxes. I'll probably do this synchronously, so the
check doesn't change state until the database confirms the update. This
way I don't need a "Save" button. Our database has never failed, so no
problem there. Occasionally the user will wonder why there's a slight
delay in the checkbox responding, but I've seen worse delays caused by
paging.

If I did this asynchronously, the user might click on the checkbox,
notice that it didn't change state instantly, and click it again.
Handling this would be tricky (especially with my level of
Javascript/Ajax skills) and wouldn't improve the user experience.

Mind you, I'm the user as well.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
 
Reply With Quote
 
optimistx
Guest
Posts: n/a
 
      08-29-2008
Steve Swift wrote:
....
> Handling this would be tricky (especially with my level of
> Javascript/Ajax skills) and wouldn't improve the user experience.


It might be simpler to program than you think:

http://yuiblog.com/blog/2006/04/04/s...-asynchronous/

Why not set a flag, when the operation starts, and reset it, when complete?
New requests are not accepted, if the flag is set.


 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      08-29-2008
optimistx wrote:
> zalek wrote:
>> I am writing application with Ajax in sync mode -
>> xmlHttp.open("GET", url, false).
>> I noticed that in FireFox handler doesn't starts. It
>> starts when I use xmlHttp.open("GET", url,true).
>> I need to use it in sync mode. Any ideas what can I do?

<snip>
> Is this correct:
> If the response for any reason does not come immediately but
> e.g. in 20 seconds (or never!) the whole browser page is like
> dead, keyboard dead, mouse clicking has no effect, the user
> becomes angry and desperate, goes away from your page and
> never comes back. Or ...?


The user does not necessarily get to go away because synchronous
requests can block the entire browser, so no navigation options are
functional while the request is going on (obviously that can vary
depending on the browser, but is true of IE 6 at absolute minimum). IE 6
also crashes (with a 'do you want to tell Microsoft about this' dialog
on XP) if you attempt to shut it down while a synchronous request is
incomplete.

It has appeared to me that the most common reason for using synchronous
requests is precisely that they do block the browser, preventing any
user interaction. The alternative would be to write code that
managed/coordinated the multiple asynchronous triggers of code execution
(user triggered events and HTTP XML responses), possibly involving
actively blocking user input. Coding this type of thing is obviously
more complex than allowing the side effects of a synchronous request to
render it moot. But that does not mean the effort should not be part of
any AJAX design.

When AJAX was formally proposed the suggested architecture explicitly
included a management/coordination/sequencing layer on the client
labelled "the AJAX Engine". Over time the AJAX buzzword has been
degraded to refer to any XML HTTP request based background loading
system, and the "AJAX Engine" notion has mostly fallen by the wayside.
Probably precisely because it is the difficult part to handle. The needs
of asynchronous request management, coordination and sequencing will
vary considerably between application contexts so no single general
"AJAX Engine" would be appropriate; either being well over the top in
some contexts and/or significantly inadequate it others. Thus while
various 'frameworks' attempt to offer AJAX in reality they rarely go
much beyond providing a wrapper around the HTTP XML request/response
process and mostly leave "AJAX Engine" part of the problem to the
problem to the individual using the 'framework'. (Though some (but
nowhere near all) frameworks do include request queuing and even UI
blocking facilities).

Presented with a need, not having any 'solution' presented to them on a
plate in various 'frameworks', and a task as complex as designing and
creating their own "AJAX Engine" layer, it cannot be surprising that
people would choose employing synchronous requests as there easiest way
out of the situation. And without vigorous/rigorous QA testing
(including the testing of responses to system/server and network
failures of various sorts) it is entirely possible that they may get the
impression of having gotten away with it.

Richard.

 
Reply With Quote
 
Gregor Kofler
Guest
Posts: n/a
 
      08-29-2008
Steve Swift meinte:

> I'm writing a webpage where I'll be updating our database on every
> change of the checkboxes. I'll probably do this synchronously, so the
> check doesn't change state until the database confirms the update.


Yuck. Somebody clicks, then wait (shall we click again?), then the box
gets checked. Sounds like an atrocious user experience. Set the checkbox
immediately. Then have an asynchronous XHR, and *if* an error occurs,
reset the checkbox, issue a message, whatever. You can also collect
checkbox clicks via a timeout and write several at once. This will -
given a serious application - lower the stress on your webserver and
database.

> Occasionally the user will wonder why there's a slight
> delay in the checkbox responding, but I've seen worse delays caused by
> paging.


He'll wonder becoause there are no delays with checkboxes. Normally.
With paging it is common.

> If I did this asynchronously, the user might click on the checkbox,
> notice that it didn't change state instantly, and click it again.


Not with the proper approach.

> Handling this would be tricky


No. Not more than any asynchronous communication. In short: synchronous
XHR is useless.

Gregor



--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-29-2008
Steve Swift wrote on 29 aug 2008 in comp.lang.javascript:

> GArlington wrote:
>> WHY do you need to make AJAX call "in sync mode"?

>
> It's the difference between "while you wait" and "drop it off and we'll
> call you when its ready". Many people prefer the "while you wait"
> approach. It's certainly simpler. For some processes, it is the only one
> that makes sense (for example, going to the dentists).
>
> Let's see how you get on at the next trip to the dentists if they say
> "Drop them off and we'll call you when they're ready".


var D = nice Dentist();

while (holes in one)
nextChild.dropOff(D);
while (holes in one)
nextSibling.dropOff(D);

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Window.open. Works in ie6. Does not work in firefox dlf Javascript 5 06-09-2008 04:07 PM
sync.rb difference between Sync::UN, Sync::EX and Sync::SH Trans Ruby 2 12-12-2005 02:43 PM
Form does not work in firefox, but works in IE sipuebla@gmail.com Javascript 4 10-17-2005 01:32 PM
<img onload= does not work in FireFox 1.0 but works in IE Luke Venediger Javascript 3 03-08-2005 08:15 PM
Webservice works once and then DOES NOT seem to work even though program does not crash Phi! ASP .Net Web Services 1 04-23-2004 08:42 AM



Advertisments