Fragment: the XML file cannot be correctly parsed in IE

Source: Internet
Author: User

Jack encountered a problem in csdn http://topic.csdn.net/u/20101018/15/c94fc92a-2e39-4f7d-a5ba-1052a8a53ff4.html

The Ajax method of jquery is used to request the XML file in the background. There is no problem with the request in FF, but the Ajax request fails in IE.

 

After reading it, I found that datatype is a limited XML file, and its XML file itself is not a problem. That is, ie load is not processed as an XML file, google found that the problem was indeed handled by IE load as text. After datatype: Text, success (the callback after the request is successful) can be performed ).

The code in this success function can be processed in this way.

 

VaR xmldoc; if ($. browser. MSIE) {xmldoc = new activexobject ("Microsoft. xmldom "); xmldoc. async = false; xmldoc. load (data); // data is the responsetext} else {xmldoc = document. implementation. createdocument ('','', null); xmldoc. load (data );}
It is not very convenient to do so.
As a result, after reading other advanced people's statements on the internet. Paste ANOTHER METHOD

Datatype: $. browser. MSIE? "Text": "XML" Var XML; If (typeof DATA = "string") {xml = new activexobject ("Microsoft. xmldom "); XML. async = false; XML. load (data) ;}else {xml = data ;}
So far, this problem has been solved. Although jquery has made a lot of effort on browser compatibility, it is still impossible to cover all aspects. I want
It has long been realized that jquery may not give us the ultimate compatibility. Maybe this problem can be solved soon. My personal memory is not good, so
Record hazi ~~

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.