运行使用XMLHttpRequest下载的JavaScript [英] Running JavaScript downloaded with XMLHttpRequest

查看:135
本文介绍了运行使用XMLHttpRequest下载的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站在用户点击链接时使用XMLHttpRequest加载信息。该系统运行良好,但我希望能够执行此过程中收集的JavaScript。

I have a site that loads information using the XMLHttpRequest when a user clicks a link. The system works well but I would like to be able to execute JavaScript gathered in this process.

这是一个问题,因为我想下载脚本按需如果是,而不是在页面加载时加载它们。

This is a problem as I would like to download the scripts 'on demand' if it were, rather than loading them all when the page is loaded.

感谢任何帮助

推荐答案

您可以使用

eval()

然而,我建议您添加新的

However I would recommend you to add new

<script src='..'></script>

到您的文档,并有一个回调,将被下载的时候被调用。有很多utils和jQuery插件。

to your document and have a callback which will be called when it will be downloaded. There are many utils and jquery plug-ins for that.

这篇关于运行使用XMLHttpRequest下载的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆