Parsererror and TypeError occur when jquery accesses XML data in IE: the solution to object error is missing

Source: Internet
Author: User
Tags comparison table
Document directory
  • Test. xml
  • Test.html
  • Running result
  • Solution

Jquery version: 1.4.4
IE version: 8.0
Error message: parsererror, typeerror: the object is missing

Test. xml

<?xml version="1.0" encoding="utf-8"?><rows><row><id>1</id><name>a.wav</name></row><row><id>2</id><name>b.wav</name></row><row><id>3</id><name>c.wav</name></row></rows>

Test.html

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

Running result

Solution: Change the JavaScript code:
$.get("test.xml", function(data) {var xml = null;if ($.browser.msie) {xml = new ActiveXObject("Microsoft.XMLDOM");xml.async = false;xml.loadXML(data);} else {xml = data;}$(xml).find("row").each(function() {alert($(this).find("name").text());});});

Related reading: Comparison Table of XMLHttpRequest object (Ajax) Status Code (readystate) and HTTP status code (Status)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.