• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

AJAX in IE

I'm having trouble with my AJAX script at http://sloaepi.dyndns.org/brothers/mkosbie/imager.ff.html .  I'm getting the error "Parameter entity must be defined before it is used" when I try to load the responseText into the XML Document container.  The page is setup right now to alert the response text, then alert the error message, then alert the length of the getElementsByTagName array I'm trying to get to.

I'm no expert in XML, but I'm pretty proficient with JS DOM and String manipulation, so I can make the XHTML look like whatever it needs to make this work.
0
netsmithcentral
Asked:
netsmithcentral
  • 2
  • 2
1 Solution
 
den_tsopaCommented:
The major problem here is that you're trying to load and parse (using loadXML) a HTML document which is not XHTML.
You cannot just change DOCTYPE declaration to XHTML.
See the W3C article about HTML4 and XHTML differences:
http://www.w3.org/TR/xhtml1/#diffs.

The second problem is that Microsoft XML library does not parse XHTML 1.1 DTD:
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd. I think this is the root cause of getting "Parameter entity must be defined before it is used" messages.
The solution here is to use XHTML 1.0 instead of XHTML 1.1.
The suggested change in parseXML function:
      var re = /(\<\!DOCTYPE[^>]+>)/;
      doc = doc.replace(re, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
0
 
netsmithcentralAuthor Commented:
I know you can't call HTML XHTML.  They are similar enough though, that if i know what kind of data to expect from the server, I should be able to parse XHTML from HTML.  At any rate, I'm now gettin the error "use of default namespace declaration attribute in dtd not supported".  I googled it, and came up with needing to include the xmlns attribute, so I added that.  No luck.  Any ideas?
0
 
den_tsopaCommented:
Try this:
 doc = doc.replace(/<html>/, '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">');
It should solve namespace problem.
0
 
netsmithcentralAuthor Commented:
Finally got it working (changed the addy to /ieXML.html).  I've decided it's easier to just use text manipulation for any non XML document though.  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now