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!