Jump to content

XMLHtpsRequest IE vs. Chrome


Rominall

Recommended Posts

So, I am really confused. At first I thought my problem was because my server wouldn't support GET/POST but now I'm not so sure as Firefox can use the GET.

 

My code works in Firefox but not IE9 or Chrome.

<html><body><script>//var xhr = new XMLHttpRequest();//var parser = new DOMParser();//var doc = parser.parseFromString(xhr.responseText, 'text/xml');if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.open("GET","RepXML.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>");var x=xmlDoc.getElementsByTagName("rep");for (i=0;i<x.length;i++)  {   document.write("<tr><td>");  document.write(x[i].getElementsByTagName("Rep")[0].childNodes[0].nodeValue);  document.write("</td><td>");  document.write(x[i].getElementsByTagName("RepID")[0].childNodes[0].nodeValue);  document.write("</td></tr>");  }document.write("</table>");</script></body></html>

What's up? What do I need to check? I would love this to work in IE9+ as that is my audience's default browser.

Link to comment
Share on other sites

@davej

Those tags are in his XML document.

 

@Rominall

Aside from not using document.write, you should also be using your developers tool to be monitoring the console for any errors, and the networks tab to confirm that request is going out and returning correctly

 

note: I am moving this thread to the Javascript forum.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...