IE AJAX bug - SOLVED
Posted: Tue Dec 05, 2006 6:41 pm
Hi all! I'm trying to make a request to the server using AJAX. It works fine in Firefox but fails in IE. The only difference I have been able to determine is that Firefox is ok with the page extension as ".php" but IE is not. I replaced the file I was calling with a file with identical output but with an extension of ".xml" and IE took it and was happy as a clam. Has anyone run into this before? Below is my code:
//the original link that makes the request
//sending the request
//the function outputSomething()
I'm totally stumped. getSigDef.php fails while sigDef.xml works perfectly.
Here's the XML I'm using
Thanks for any and all help!
//the original link that makes the request
Code: Select all
<a href="javascript:void(0);" onclick="sendAjaxRequest('getSigDef.php','id=1&sigid=1','outputSomething');">
Click here to do something
</a>
//sending the request
Code: Select all
function sendAjaxRequest(url,params,functionName)
{
var http_request = getObject();
if (!http_request)
{
return false;
}
else
{
http_request.onreadystatechange = function()
{
eval(functionName)(http_request);
};
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.setRequestHeader("Content-Length",params.length);
http_request.send(params);
}
}
Code: Select all
function outputSomething(http_request)
{
var ready = http_request.readyState;
var data = null;
var outputSnippet = "";
if(ready == 4)
{
if (http_request.responseText.indexOf('invalid') == -1)
{
var myXML = http_request.responseXML;
var sigDef = myXML.getElementsByTagName('sig');
if(sigDef.length >0) //this is where it dies.
//firefox returns 1, IE always returns 0
{
for (t=1;t<6;t++)
{
//load stuff into an array
}
for (t=0;t<7;t++)
{
//load stuff into an array
}
}
else
{
alert("no nodes found");
}
}
}
else
{
//waiting...
}
}
I'm totally stumped. getSigDef.php fails while sigDef.xml works perfectly.
Here's the XML I'm using
Code: Select all
<?xml version="1.0"?>
<def>
<sig>
<p1name>A</p1name>
<p2name>B</p2name>
<p3name>C</p3name>
<p4name>D</p4name>
<p5name>E</p5name>
<p1Qty>0</p1Qty>
<p2Qty>0</p2Qty>
<p3Qty>0</p3Qty>
<p4Qty>0</p4Qty>
<p5Qty>0</p5Qty>
<d0>0</d0>
<d1>0</d1>
<d2>0</d2>
<d3>0</d3>
<d4>0</d4>
<d5>0</d5>
<d6>0</d6>
<withorwithout>0</withorwithout>
</sig>
</def>