Home >Web Front-end >JS Tutorial >Using AJAX to return JavaScript scripts in HTML fragments_javascript tips
This is a very common problem in AJAX development. If you have not been using JavaScript frameworks for development, I believe you have discovered this problem long ago. This article analyzes two solutions, one of which explains the implementation of the jQuery framework.
1. Problem description
The following is a simple example to demonstrate the problem. In the following example, assume that the variable responseText is the HTML fragment data loaded by AJAX, which contains a script to pop up a message. Use the innerHTML method to insert it into the DIV with the ID ajaxData. You may expect to see the message box pop up, but you find that it does not. That's the problem.