重新加载使用 jQuery
好吧,所以我知道这是非常奇怪和不正常的,我可能应该避免它,但这就是我想做的。我基本上想通过 jQuery 重新加载标头中的每个 。您可以使用
.load(url+" #element")
,但这仅适用于具有 ID 而非标签的元素。
如何选择并重新加载文档中的所有脚本?
谢谢
Okay, so I know this is very weird and abnormal and I should probably avoid it, but this is what I want to do. I basically want to reload every <script>
in the header through jQuery. You can use .load(url+" #element")
, but that's only for elements with an ID not with a tag.
How can I select and reload all the scripts in a document?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我了解,您要做的是将更多 JS 加载到页面上。如何使用 AJAX(以 PHP 作为后端)获取 JS 文件的内容(作为字符串),然后使用 Javascript 的 eval() 函数在客户端执行它。
As I understand it, what you're trying to do is load more JS onto the page. How about fetching the contents of the JS file (as a string) using AJAX (with say PHP as the backend) and then executing it on the client side using Javascript's eval() function.
最好的选择是在头部重新添加每个脚本标签。
我粗略地测试了一下,似乎效果很好。
Your best bet is to just re-add every script tag in the head.
I did a cursory test, and it seemd to work fine.
我找到了问题的替代解决方案,为了安全起见,我走了很长的路。谢谢你们的回答。这里绝对有一些有用的信息。
I found an alternate solution to the problem and took the long route just to be safe. Thanks for the answers guys. Definitely some useful info in here.