[Solved perfectly] 'document. getelementbyid (…) under IE (...) 'Is null

Source: Internet
Author: User
View code

1 $. Ajax ({
2 type: "Post", // Request Method
3 URL: "text.txt", // address, which is the Action Request Path
4 cache: false,
5 Data: "text", // data type text xml json script jsonp
6 success: function (MSG) {// The returned parameter is all the get and set parameters in the action.
7 document. getelementbyid ("result"). innerhtml = MSG;
8 alert (document. getelementbyid ("result "));
9}
10 });

The above code is correct in FF, but the 'document. getelementbyid (...) 'is null error will be reported in IE.

Goolge + Baidu: it is more reliable to say that the header file is added with a line of life, and IE8 mode is forcibly switched to IE7 mode.

The problem persists. If it is not found or empty, it indicates that the tag is not found. Therefore, place the reference of this JS file under the tag. OK. The problem is solved:

<Div id = "result"> </div>
<SCRIPT src = "Ajax. js"> </SCRIPT>

Thinking is really important!

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.