[thelist] JavaScript/Ajax - responseText and IE question

Tom Dell'Aringa pixelmech at yahoo.com
Thu Mar 2 12:17:42 CST 2006


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 = "<p>We're sorry but there is a problem with our mailing list. Please try again
later.</p>";
   //TODO: Send myself a notification that there is a failure.
}
else
{
	$strResponse = "<p>You have successfully been added to the mailing list.</p>";
}

// 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


http://www.pixelmech.com/
http://www.crossandthrone.com/


Professor Rumford: 'But I still don't understand about hyperspace.' 
The Doctor: 'Well, who does?' 
K9: 'I do.' 
Doctor: 'Shut up, K9!' 





More information about the thelist mailing list