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

J

Jorge

With a context-devoid, *stateless* , pile-of-pooh like HTTP, the options
are clearly limited. (...)

Richard, the way I see it http has proved to be quite handsome (much
more than enough).
And lots of things can be done with it just needs a little bit more
verbosity than usual.
If on the other hand you were to use a socket setup, similar to the example
that I posted, then the server would be notified of socket disconnection and
could take appropriate action to quiesce whatever it was doing. (There is
also an example of a hot-abort button; so if a given query is taking too
long, the clicking of the button will send an OOB character down the line..
In this case the query can be cancelled, yet the connection maintained.)

A copy of the Java Applet code is at: -http://manson.vistech.net/t3$examples/

But client-side Java... is it that stinky cold dying corpse ?
I'd rather wait for HTML5, and in the meantime will keep fudging with
http/XHRs.

:)

Regards,
 
S

Steve Swift

Jorge said:
Yes and no. It's not the same thing to disable a form's UI than to
have the app's UI (either a standalone GUI app or a browser) hanged.

True (and my work colleagues are complaining about a single-threaded
application that we we have to use that becomes unresponsive when doing
I/O to large files).

However, the page I was discussing has only one user, me, and since my
job is to keep the server running, having my entire browser hang when
something goes wrong is just about the *best* way to get my attention. :)
 
G

GArlington

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". :)
It thould be perfectly all right with my thet of dentureth...
But, I guess you will not object if they offer you to watch a movie in
3-D glasses while the are working on your teeth...
 
G

GArlington

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.
How about you change the state on client side immediately, send
request to server to update DB, and notify the user if there are any
problems...
 
M

Michael Wojcik

Richard said:
With a context-devoid, connectionless, pile-of-pooh like HTTP, the options
are clearly limited.

HTTP is sessionless. It's not connectionless (at least not over TCP,
which is the only transport used in practice). And when the client
does its close or half-close, the HTTP server will get a FIN (modulo
network failure), just like any other TCP application.
If on the other hand you were to use a socket setup, similar to the example
that I posted, then the server would be notified of socket disconnection

Nothing in the sockets API makes that guarantee.

If it's a stream socket, over TCP, then if the client closes its end,
the client-side stack will try to send a FIN (or an RST, depending on
what kind of half-close the client does and other complications) to
the peer. That packet may or may not arrive. If it does, the
server-side stack will update its state, and report it to the server
in the appropriate manner. That's usually returning length 0 from a
receive operation, or returning the appropriate error indication from
a send operation.
could take appropriate action to quiesce whatever it was doing.

Not unless it checks, unless the server is using some mechanism (such
as Unix SIGIO) that lets the stack interrupt it. Also not part of the
sockets API, and completely outside the client's control.

What HTTP offers the client for aborting an operation on the server is
perfectly adequate for most purposes. Either the server pays attention
to the client's side of the connection, or it does not. Having the
client send an abort message on the HTTP request channel would add no
value; if the server's not checking that channel, it's not checking
that channel.

There are good reasons why HTTP does not use a separate control
channel (as eg FTP does). For one thing, it's a PITA for stateful
firewalls.

This is a slight simplification. There's no way for the server to
distinguish between a full, normal close by the client, and a client
half-close, except by trying to send data. In principle, a client
could send its request and then half-close the conversation, if it
doesn't want to send more data. However, RFC 2616 appears to encourage
servers to treat that as a full close:

-----
When a client or server wishes to time-out it SHOULD issue a graceful
close on the transport connection. Clients and servers SHOULD both
constantly watch for the other side of the transport close, and
respond to it as appropriate.
----- (8.1.4)

Since 2616 doesn't distinguish between half-close and full-close, it
appears that fully-compliant HTTP/1.1 servers have to detect a client
close of whatever sort (if possible) and terminate processing that
request.

That's already in the HTTP spec. There's no need to create another
protocol just to get that behavior, and as Jorge wrote, there's no
need for the client to do anything else. If the server is left
grinding, that's because the server isn't fully compliant with the
HTTP spec.
 
R

Richard Maher

Hi Jorge,
But client-side Java... is it that stinky cold dying corpse ?

That's my kind of rhetoric :) In this case however I think you'll find Java
alive and well. (If more for infrastructure code rather than straight GUI)

These links may also be of some interest: -
http://weblogs.java.net/blog/joshy/archive/2008/05/java_doodle_cro.html
https://jdk6.dev.java.net/plugin2/

If you don't like Java there's always Flex. I believe Flex's Socket support
to be rudimentary at best with: -
.. No connect Timeout
.. No OOB support
.. No UDP
but if you're already incorporating Flex into your Web apps (or AIR) then
why not? (Actually, in this case, I'd still use Java along side Flex and the
Adobe FABridge, but each to his own. See
http://manson.vistech.net/t3$examples/demo_client_flex.html for an example
of getting data from a Java Socket and populating a Flex DataGrid for
presentation in Flex charting. Once again, all source including MXML file
can be found at http://manson.vistech.net/t3$examples/ )
I'd rather wait for HTML5

If you are refering to WebSockets with HTML5 then I obviously have to say
"What a great idea!". But what an absolute bollocks implementation :-( If
anyone has any input at all with these guys can you please ask them to go
back to the drawing board and work out what a socket actually is. Yes, we
*want* WebSockets but not some piece o' shit implementation as the God of
HTTP would've intended!)

Also interesting that Flex, SilverLight, and now Java are all adopting the
cossdomain.xml "standard". It would be nice if Microsoft introduced Socket
support in SilverLight but then it's so far behind Flex that it's probably
not an issue?
and in the meantime will keep fudging with
http/XHRs.

Why not, that's what everyone else does; and fudging things what the web's
all about :)

Cheers Richard Maher

With a context-devoid, *stateless* , pile-of-pooh like HTTP, the options
are clearly limited. (...)

Richard, the way I see it http has proved to be quite handsome (much
more than enough).
And lots of things can be done with it just needs a little bit more
verbosity than usual.
If on the other hand you were to use a socket setup, similar to the example
that I posted, then the server would be notified of socket disconnection and
could take appropriate action to quiesce whatever it was doing. (There is
also an example of a hot-abort button; so if a given query is taking too
long, the clicking of the button will send an OOB character down the line.
In this case the query can be cancelled, yet the connection maintained.)

A copy of the Java Applet code is
at: - http://manson.vistech.net/t3$examples/

But client-side Java... is it that stinky cold dying corpse ?
I'd rather wait for HTML5, and in the meantime will keep fudging with
http/XHRs.

:)

Regards,
 
Z

zalek

xmlHttp.open("GET", url, ** false **);


If you're running this in FF3, see cljs thread # ce635b45f594fc64 "A
bug in FF3's sync XHRs ?"

Thanks Jorge for your help,

I solved my problem and now my Ajax code is working in sync mode in FF
and IE. Just in case someone else will have a similar problem, here is
my code:

function validate_user_info() {
try {
// Firefox, Opera 8.0+, Safari
w_browser = "Firefox" ;
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
w_browser = "IE" ;
}
catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
w_browser = "not FireFox and not IE" ;
}
catch (e) {
alert("Your browser does not support AJAX!");
return ;
}
}
}

ajax_user_info();
return ;
}

function ajax_user_info() {
var url = "ajax_server.jsp?office=" +
document.forms[0].office.value +
"&car=" + document.forms[0].car.value ;

if (w_browser == "Firefox") {
xmlHttp.open("Get", url, false);
xmlHttp.onreadystatechange = handleHttpResponse;
}
else {
xmlHttp.open("Get", url, false);
xmlHttp.onreadystatechange = handleHttpResponse;
}
xmlHttp.send(null);
if (w_browser == "Firefox") {
i = 0;
while((i < 9) && (xmlHttp.readyState != 4) ) {
i++;
handleHttpResponse() ;
}
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200){
var message = xmlHttp.responseText ;
alert (message) ;
}
}
}
return ;
}

function handleHttpResponse() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200){
var message = xmlHttp.responseText ;
if (message.substr(0,2) != "ok") {
alert (message) ;
}

}
}
}


I am using code:
while((i < 9) && (xmlHttp.readyState != 4) ) {
i++;
handleHttpResponse() ;
}

in case Ajax server is slow, to gaine some time.

Zalek
 
R

Richard Maher

Richard Maher said:
Hi Jorge,


That's my kind of rhetoric :) In this case however I think you'll find Java
alive and well. (If more for infrastructure code rather than straight GUI)

These links may also be of some interest: -
http://weblogs.java.net/blog/joshy/archive/2008/05/java_doodle_cro.html
https://jdk6.dev.java.net/plugin2/

If you don't like Java there's always Flex. I believe Flex's Socket support
to be rudimentary at best with: -
. No connect Timeout
. No OOB support
. No UDP
but if you're already incorporating Flex into your Web apps (or AIR) then
why not? (Actually, in this case, I'd still use Java along side Flex and the
Adobe FABridge, but each to his own. See
http://manson.vistech.net/t3$examples/demo_client_flex.html for an example


Sorry, forgot the login information: -

Username: TIER3_DEMO
Password: QUEUE
 
R

Richard Maher

Hi,
Also interesting that Flex, SilverLight, and now Java are all adopting the
cossdomain.xml "standard". It would be nice if Microsoft introduced Socket
support in SilverLight but then it's so far behind Flex that it's probably
not an issue?

While looking for something else in Silverlight yesterday I stumbled across
some version 2 beta documentation that says that Microsoft has in fact
introduced native Socket support for Silverlight. Yippee! (Albeit TCP only
at this stage.)

So I once again beseech you - if you know or can influence anybody involved
in the HTML5 WebSocket design team, please tell them that they are getting
it horribly, horribly wrong! Java, Flex, and now Silverlight are all giving
us full-on unrestricted-content binary socket support and yet these
knob-heads are tying us up in knots and doing everything they can to make it
look/behave like HTTP. I guess that's all they know, or at least all they're
used to :-(

Please, please, please give us complete access to the same Sockets that have
been around for a million years and stop trying to fashion them in your
likeness. If you're confined to talking to http servers then by all means
stick an additional interface or abstraction on top for those who'll see fit
to use it, but there are many of use that have no interest in being shackled
by such nonsense.

What goes up and down the network connection is our business; not yours! NO
MORE BOLLOCKS PROTOCOLS!

Cheers Richard Maher
 
R

Richard Maher

Hi Ian,

[You yourself can influence the HTML5 work -- just join and post on the
WHATWG mailing list:]

I'll give it a go, and desperately hope that others will do the same.

Thanks for the Info.

Chhers Richard Maher

So I once again beseech you - if you know or can influence anybody involved
in theHTML5WebSocket design team [...]

You yourself can influence the HTML5 work -- just join and post on the
WHATWG mailing list:

http://www.whatwg.org/mailing-list#specs

All feedback sent to that list is read and will in due course receive
a reply.
 
E

efischer

I agree with all you guys have said about how to write better code and
how to workaround the sync call problem. But the main point is that
this IS A BUG in FF3 and it should be fixed, it doesn't matter if it
is a good practice to use it or not.

This is in reality a very old bug from early FF1 versions that was
fixed as a side effect of some other fix in later FF1 versions. All
bugzillas about sync requests are still open since FF1, there was
never an explicit fix for it. Now in FF3 it came live again :(

-Ernesto
 
T

Thomas 'PointedEars' Lahn

[...] But the main point is that this IS A BUG in FF3 and it should be
fixed, it doesn't matter if it is a good practice to use it or not.

What are you referring to?


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top