Ajax / Safari Problem

K

Kalyke

When I try to run my page in safari I get this error msg:
Value undefined (result of expression xmlDoc.load) is not object.

The script works brilliantly in IE and firefox. I'm not sure how to
fix this. I'd appreciate any help here is the code thats causeing the
problem:

try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
var x=xmlDoc.getElementsByTagName('picture');

}
catch(e)
{
try //try Firefox, Mozilla, Opera, etc.
{
var xmlDoc = new XMLHttpRequest();
xmlDoc=document.implementation.createDocument("","",null);
} catch(e)
{
alert(e.message);
}
}
//Creates array out of imaes in xml file

xmlDoc.async=false;
xmlDoc.load('pictures.xml');
var x=xmlDoc.getElementsByTagName('picture');
var numXml = x.length;
var setNumbers = numXml / 4;
for (i=0;i<numXml;i++)
{
srcArray = xmlDoc.getElementsByTagName("src")
.firstChild.nodeValue;
altArray = xmlDoc.getElementsByTagName("alt")
.firstChild.nodeValue;
img = "<img src=\'"+srcArray+"\' onClick=\'replaceMain("+i+")\'
onmouseover=\"this.style.cursor=\'pointer\'\" alt=\'"+altArray+"\'
width=144 height=108 >";
imageArray = "<li>"+img+"</li>";
}
}
catch(e){alert(e.message)}
 
M

Martin Honnen

When I try to run my page in safari I get this error msg:
Value undefined (result of expression xmlDoc.load) is not object.

Safari does not support the load method on a DOM document object. Use
XMLHttpRequest instead to load the pictures.xml document, then access
the responseXML property.
 

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
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top