search
HomeWeb Front-endJS TutorialUsing 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.

Copy code The code is as follows:


Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool