AJAX

Moderators: None (Apply to moderate this forum)
Number of threads: 61
Number of posts: 110

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Microsofx.XMLDOM.load() returns nothing? Posted by AdmiralNemo on 4 May 2008 at 2:36 PM
Hi all,

I am doing some work in cross-browser AJAX, and I have run into a problem with Internet Explorer. No big surprise here, but this time, I can't find a solution.

Basically, I have a function that attempts to load and parse an XML document that was created dynamically in PHP on the server-side. This works great in Firefox, but in Internet Explorer, it does not.

This is the function that loads the remote document by URL. If I pass the URL to a document ending in ".xml," the alert displays the number of tags in it, as it should. However, if I pass the URL of a .php file that generates the exact same content as the xml file, the element count is 0.

function loadXMLDoc(url) {
 if(window.ActiveXObject) {
  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async = false;
  xmlDoc.load(url);
  alert(url + ": " + xmlDoc.getElementsByTagName("*").length);
  }
 else if(document.implementation && document.implementation.createDocument) {
  xmlDoc = document.implementation.createDocument("","",null);
  xmlDoc.async = false;
  xmlDoc.load(url);
  }
 return xmlDoc;
 }


Some questions you may ask:

"Does the PHP file set the HTTP Content-Type header correctly?"
Yes. Apache sends "application/xml" for xml documents, so I set PHP to do the same. Also tried "text/xml" with no love.

"Is the XML valid?"
Yes. I even tried it with a simple one-empty-element document with the same effect.

If anyone has suggestions, I would really appreciate it.

Thanks
Dustin
Report
Re: Microsofx.XMLDOM.load() returns nothing? Posted by AdmiralNemo on 5 May 2008 at 6:47 AM
Well, I figured it out. Apparently, Microsoft.XMLDOM.load refuses to load SSL encrypted pages that send no-cache headers.

This bug is documented by Microsoft: http://support.microsoft.com/kb/272359

: Hi all,
:
: I am doing some work in cross-browser AJAX, and I have run into a
: problem with Internet Explorer. No big surprise here, but this time,
: I can't find a solution.
:
: Basically, I have a function that attempts to load and parse an XML
: document that was created dynamically in PHP on the server-side.
: This works great in Firefox, but in Internet Explorer, it does not.
:
: This is the function that loads the remote document by URL. If I
: pass the URL to a document ending in ".xml," the alert displays the
: number of tags in it, as it should. However, if I pass the URL of a
: .php file that generates the exact same content as the xml
: file, the element count is 0.
:
:
: function loadXMLDoc(url) {
:  if(window.ActiveXObject) {
:   xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
:   xmlDoc.async = false;
:   xmlDoc.load(url);
:   alert(url + ": " + xmlDoc.getElementsByTagName("*").length);
:   }
:  else if(document.implementation && document.implementation.createDocument) {
:   xmlDoc = document.implementation.createDocument("","",null);
:   xmlDoc.async = false;
:   xmlDoc.load(url);
:   }
:  return xmlDoc;
:  }
: 
:
:
: Some questions you may ask:
:
: "Does the PHP file set the HTTP Content-Type header correctly?"
: Yes. Apache sends "application/xml" for xml documents, so I set PHP
: to do the same. Also tried "text/xml" with no love.
:
: "Is the XML valid?"
: Yes. I even tried it with a simple one-empty-element document with
: the same effect.
:
: If anyone has suggestions, I would really appreciate it.
:
: Thanks
: Dustin
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.