加载JavaScript穿过jQuery的AJAX的负荷?负荷、加载、jQuery、JavaScript

2023-09-10 18:21:43 作者:挽歌

我有一个JavaScript的,我放入用下面的code的页面。什么是code的作用是放置一个对象/嵌入code到网页。简单的JavaScript加载到NicoVideo电影

 <脚本类型=文/ JavaScript的SRC =htt​​p://ext.nicovideo.jp/thumb_watch/sm13154955?w=640&h=395>&LT ; / SCRIPT>
 

本网页中的伟大工程。但是,如果我要加载这个JavaScript到使用AJAX网页是什么?这不再是明显的原因工作的,你需要EVAL为了得到它来运行脚本。不过,我不知道如何做到这一点。我使用jQuery我的网页上;所以记住这一点。我曾尝试以下code,但它似乎并没有通过AJAX的工作,甚至在正常的网页加载环境。

<script>$.getScript("http://ext.nicovideo.jp/thumb_watch/sm13154955?w=640&h=395");</script>

我怎么会得到任何想法这个工作?

解决方案

我觉得它的工作原理,但其试图内联,我不知道这是否会工作在这种情况下写。

Hybrid APP技术原理

您需要看是否有办法从根本上执行.getHTML'的方法,并采取这一结果和更新现有的元素在页面上。

问题是,虽然已生成并执行内联的匿名功能可能无法正常工作。

I have an javascript that I place into a page using the code below. What the code does is place an object/embed code into a webpage. Simple javascript loader to a NicoVideo movie

<script type="text/javascript" src="http://ext.nicovideo.jp/thumb_watch/sm13154955?w=640&h=395"></script>

This works great in a webpage. But what if I want to load this javascript into a page using AJAX? This no longer works for the obvious reasons, you would need to eval the script in order to get it to run. However, I have no idea how to do this. I am using jQuery on my page; so keep that in mind. I have tried the following code, but it doesn't seem to work through AJAX, or even in a normal page load environment.

<script>$.getScript("http://ext.nicovideo.jp/thumb_watch/sm13154955?w=640&h=395");</script>

Any ideas on how I would get this to work?

解决方案

I think it works but its attempting to inline the write which I don't know if that would work in this case.

You would need to see if there was a way to essentially execute the '.getHTML' method and take that result and update an existing element on the page.

The issue though is that the anonymous function that is generated and executed inline might not work properly.