Ajax, Firefox keeps saying "waiting for ..."

  • Thread starter Bart van Deenen
  • Start date
B

Bart van Deenen

Hi All

I'm happily creating an Ajaxified web-app. I use Prototype for
encapsulating xml http requests, with method "post". On the backend, I
use PHP, and the replies are eval'd by Javascript. I do not use XML for
data encapsulation.
The only thing that is off nominal is that my Firefox 1.07 (Mac OS-X)
and 1.06 (Linux) have "Waiting for ..." continuously in the status bar.

I know from server debugging and packet sniffing that there is no more
data communication. The server reply has already been handled so that
functionally I have no problems at all. I am just wondering if there is
something I'm doing wrong on the PHP side: the code is this.

function xhr_reply($re){
header("Content-type: text/xml");
print $re;
die;
}

I know it's really php, but it seems to me this is the usenet place for
xml http request type problems.

Thanks for any enlightenment.

Bart
 
B

Bart van Deenen

Hi Chuck

chuck said:
Have you gotten a really simple example to work? Just send a variable
with GET or POST and have the php just send it back to you. handle
the response with the onSuccess function.

post your ajax call and php function to get a better answer.

Thanks for your answer. Unfortunately, it is not reproducible with a
really short example :-( Fortunately now I know it's a bug somewhere in
my app, so I can go looking for it.

My app is quite complicated with multiple xhr's running simultaneously
generated from dynamic data. Maybe one of them is wrongly addressed or
so, and I haven't noticed it up to now.

Greetings

Bart



The stuff below works fine

--------------------- a.html --------------
<html >
<head>

<script language="JavaScript" type="text/javascript" src="prototype.js"
</script>

<script type='text/javascript' >

function assignError(e){ $("id_error").innerHTML = e; }
function assignSuccess(e){ $("id_success").innerHTML = e; }

function xhr(){

new Ajax.Request( 'a.php', {
asynchronous: true,
method: "post",
parameters: "test="+$F('id_text'),
onSuccess: function(request) {
assignSuccess(request.responseText);
},
onFailure: function(request) {
assignError(request.responseText);
}
});
}
</script>


</head>
<body >
<div id='id_error' style='background:red'> </div>
<div id='id_success' style='background:#0d0'> </div>

<input type='text' id='id_text' />
<button type='button' onclick='xhr()' >xhr test
</button>
</html>


------------------- a.php -------------------
<?
if ( $_REQUEST['test']) {
header("Content-type: text/xml");
print "hi there ".$_REQUEST['test'];
die;
}
?>
 
M

Martin Honnen

Bart van Deenen wrote:

I'm happily creating an Ajaxified web-app. I use Prototype for
encapsulating xml http requests, with method "post". On the backend, I
use PHP, and the replies are eval'd by Javascript. I do not use XML for
data encapsulation.
header("Content-type: text/xml");

Well if you don't use XML why do you set the HTTP response Content-Type
header to text/xml then?
I think you want
header('Content-Type: text/plain');
then or perhaps
header('Content-Type: text/javascript');
I don't think that header causes the problem you see but XMLHttpRequest
will try to parse a text/xml response as XML and you can prevent it from
that useless attempt then by setting a proper Content-Type.
 
B

Bart van Deenen

Martin Honnen said:
I don't think that header causes the problem you see but XMLHttpRequest
will try to parse a text/xml response as XML and you can prevent it from
that useless attempt then by setting a proper Content-Type.
You are right, it doesn't matter. This was just the result of my
tinkering with this problem. As I posted in result to chuck, the problem
must be somewhere deeper within my app, because a trivial case doesn't
have the problem.

Bart
 
S

slick

Try setting a content length header.

function xhr_reply($re){
header("Content-type: text/plain");
header('Content-length: '.strlen($re));
print $re;
die;

}
 
R

Rick Brandt

Bart said:
You are right, it doesn't matter. This was just the result of my
tinkering with this problem. As I posted in result to chuck, the
problem must be somewhere deeper within my app, because a trivial
case doesn't have the problem.

Bart

Total newb here but our shop is migrating to web apps using Ajax and I see the
same thing in all of our stuff in Firefox. I have just been assuming that
Firefox is expecting our forms to use a standard submit action and is "waiting"
for that response.
 

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
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top