PDA

View Full Version : IE Ajax problem


unclhos
05-31-2009, 04:01 AM
I must start with I am very new with javascript. I know what I can find basically. :D But this site I am working on works on both Firefox and Chrome. But It will not work on IE and don't know why. Here is what I have:

Main Page
<td valign="top" width="40%">
<span id="gearInfo" name="gearInfo">
</span></td>

Iframe inside Main Page


<script src="showgear.js" type="text/javascript"></script>

<div class="gearitem">
<button value="<?php echo $row['type'];?>" onclick="showGear(this.value)">
<img class="thumbnail" src="images/<?php echo $row['image'];?>">
</button>
</div>

Here is a populated copy of the above code:
<div class="gearitem">
<button value="Backpack" onclick="showGear(this.value)">
<img class="thumbnail" src="images/palisade80_backpack.gif">
</button>
</div>

Here is the script:
var xmlHttp

function showGear(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getgear.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
parent.document.getElementById('gearInfo').innerHTML=xmlHttp.responseText
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

rnd me
05-31-2009, 08:40 AM
try top instead of parent in parent.document.
also try calling .open() before setting onreadystatechange.

unclhos
05-31-2009, 05:51 PM
Thank You, I have tried those two items with no success. But it does still work on chrome, so most likly Firefox too, haven't been able to check that one. Here is the link to the websites page that I am working on: www.nibiruweb.com/cyfi/gear.php

unclhos
06-01-2009, 10:28 PM
Ok so I have been researching the Problem with IE, and have tried a few things that people have said were work arounds but still with no success. I have tried using the meta tags for caching to have the page expire but still doesn't work. Anyone have any other ideas?? If not I will just have to force people to use the better web browers out there(haha).

Any tips for changing it to a POST format?