如何在设置html时保留标记

时间:2023-01-14 16:28:37

I am doing some AJAX call which returns plain HTML with some javascript code.While i set returned response to container using .html (Jquery) or innerHTML (plain javascript) it removes tag and all javascript.

我正在做一些AJAX调用,它返回带有一些javascript代码的纯HTML。虽然我使用.html(Jquery)或innerHTML(普通javascript)将容器的返回响应设置为删除标签和所有javascript。

But when I change <script type="text/javascript"> to <script type="text/xml"> it retains all script tags and javascript. But my script does not execute even no alert and congole.log work inside this.

但是当我将

Please suggest me if i can retain tag and javascript without changing type.

如果我可以保留标签和javascript而不改变类型,请建议我。

Thanks

1 个解决方案

#1


I have solved this problem before by changing my AJAX call from a GET to a POST.

我之前通过将我的AJAX调用从GET更改为POST来解决了这个问题。

#1


I have solved this problem before by changing my AJAX call from a GET to a POST.

我之前通过将我的AJAX调用从GET更改为POST来解决了这个问题。