SouthFresh Posted July 5, 2008 Share Posted July 5, 2008 I've been banging my head against the wall for four days now and can't seem to figure this one out. var XMLHttpRequestObject;var xmlDoc;var pathtoxml = "the path to my actual xml file";if (window.XMLHttpRequest){ console.log('create standard XHR'); XMLHttpRequestObject = new XMLHttpRequest();}else if (window.ActiveXObject) { console.log('Not standard, using activex'); XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");}console.log('Check if XHR exists');if(XMLHttpRequestObject) { console.log('XHR Exists, attempting GET'); XMLHttpRequestObject.open("GET", pathtoxml); console.log('Assigning handler function for XHRs onreadystatechange'); XMLHttpRequestObject.onreadystatechange = function() { console.log('if XHRs readystate is 4 then do something but right now it is: ' + XMLHttpRequestObject.readyState); if (XMLHttpRequestObject.readyState == 4) { console.log('readystate is 4, attempt to assign responseXML to xmlDoc'); xmlDoc = XMLHttpRequestObject.responseXML; console.log('xmlDoc has been assigned'); console.log('The response xml is: ' + XMLHttpRequestObject.responseXML); console.log('The doctype is: ' + xmlDoc.doctype); } } console.log('Initiate XHR.send'); XMLHttpRequestObject.send(null); } Sorry about all the console.logs that are in there, but it's been the only way for me to be able to narrow down where the issue is.The path to my xml is valid, and even returns the correct doctype in browsers that aren't Safari.Safari gets the correct stuff for responseText, but get's Null for responseXML.... what have I done wrong?Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted July 5, 2008 Share Posted July 5, 2008 I can't be sure if this will help, but I was researching the problem and found this:http://radio.javaranch.com/pascarello/2006...8096122600.html After answering the question a bunch of times in the past year, I found that the following questions will find the error 99% of the time: Did you set your content type to text/xml? Is your request actually making it to the server and back? When you alert/examine the responseText, do you see anything that does not belong? Open up the dynamic XML document in your browser directly. (Type the url into the browser. This may require you to hard code post parameters or build a test form.) The browser will tell you if your XML is not formatted correctly. Is it formatted correctly? Link to comment Share on other sites More sharing options...
SouthFresh Posted July 5, 2008 Author Share Posted July 5, 2008 I think I'd run in to the same post.1. The response comes through correctly in FF, the doctype and dtd are all in the xml response when I view the source.2. responseText works so I have to assume that the server is responding.3. Nothing appears to be missing or extra in the responseText4. I've saved the document and uploaded it to http://www.validome.org/xml/validate/ and it validates.I'm at a loss. Link to comment Share on other sites More sharing options...
Ingolme Posted July 5, 2008 Share Posted July 5, 2008 Does this XML document have a .xml extension? And if it doesn't, did you add the header() with PHP? header("Content-type: text/xml"); Link to comment Share on other sites More sharing options...
SouthFresh Posted July 5, 2008 Author Share Posted July 5, 2008 The return is definitely .xml....No php in use here, but if I switch things around so that it is only looking at a static xml file, the same results show up. Link to comment Share on other sites More sharing options...
boen_robot Posted July 6, 2008 Share Posted July 6, 2008 Try to set validateOnParse to false to the response before actually getting it, i.e. XMLHttpRequestObject.responseXML.validateOnParse = false; console.log('Initiate XHR.send'); XMLHttpRequestObject.send(null); Safari may have a problem validating the XML file, and assumes invalid.If that too doesn't work, try to remove the DTD. This will force validation off, since there won't be anything to validate against. Link to comment Share on other sites More sharing options...
SouthFresh Posted July 6, 2008 Author Share Posted July 6, 2008 Didn't seem to have an effect. I think maybe something else in my code is the culprit. I'll review and report back. Thank you for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.