When using Jquery's html (data) method to write data to Dom elements, the following problem occurs: when the data parameter contains a script block, html (data) the execution result of the method is not as expected. The Teddy's Knowledge Base2008-04-22 has also mentioned a similar problem here. The original Article is as follows:
The HTML returned by the jquery(...).html () method will filter out all <script> blocks, but sometimes, especially in AJAX applications, the <script> blocks in HTML are often reserved, for example, to partially update the content containing scripts, do not use html () to read and write HTML, or use elem honestly. innerHTML. I am sorry for the waste of one hour for this problem ."
After the test, it is found that the jquery(..).html () method that has not been verified by the new statement (1.3.2does not exist. (The html () method is an operation to read Dom element data) method when writing data to the Dom element and the data parameter contains the script, an exception occurs: execute the above operation in the Firefox (My 3.6) browser, the script in the data parameter runs automatically, causing errors such as page breaks and exceptions. For example, my problem is: there is a document in the script. after the html (data) operation is executed, the original dom elements of the entire page disappear, leaving only document. the execution result of the write () method causes a page breakdown. The specific reason is to be discussed, and elem is still used. the innerHTML = data method solves this problem and is marked here.