[thelist] JavaScript/Ajax - responseText and IE question

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Mar 2 12:21:52 CST 2006


I had that problem with ELB a while back.

Try request.ResponseText for IE.

And yes, I'm serious.

 From: Tom Dell'Aringa pixelmech at yahoo.com

Not sure if there are many Ajax folks on this list, but maybe someone has an idea to help me with
this issue. I have a very simple Ajax process running that signs a person up to a mailing list and
sends back a confirmation to the page, overwriting the join form. It works perfectly in Mozilla,
but IE is throwing a lovely "unspecified error" (man do I hate that). Using the debugger, I've
found it is complaining about the responseText. 

I'm doing the following onreadystatechange:
========================
function processRequestChange() 
{
m = document.getElementById('msg');
// only if request shows "complete"
if(request.readyState == 2 || request.readyState == 3 )
{
m.innerHTML = "working..."
}
else if (request.readyState == 4) 
{
// only if "OK"
if (request.status == 200) 
{

response = request.responseText;
m = document.getElementById('msg');
m.innerHTML = response;
} 
else 
{
alert("There was a problem retrieving the data:\n" + request.statusText);
}
}
}
=======================

It seems to die on the response and I am not sure why. The php file handling this call is adding
some GET data to a database and then ECHOs a string like so:

=======================
$strResponse = "";

$result = mysql_query("INSERT INTO ctmembers(name, email) VALUES ('$mname', '$mmail')");
if (!$result) {
die('Invalid query: ' . mysql_error());
$strResponse = " 

We're sorry but there is a problem with our mailing list. Please try again
later.";
//TODO: Send myself a notification that there is a failure.
}
else
{
$strResponse = " 

You have successfully been added to the mailing list.";
}

// Close connection
$DB->disconnect();

echo $strResponse; <-- this should be the responseText
====================================

For some reason Mozilla grabs this but IE won't - anyone know why?

Thanks

Tom



More information about the thelist mailing list