Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用AJAX从另一个页面执行Javascript_Jquery_Yahoo Api - Fatal编程技术网

Jquery 使用AJAX从另一个页面执行Javascript

Jquery 使用AJAX从另一个页面执行Javascript,jquery,yahoo-api,Jquery,Yahoo Api,我正在尝试从另一个使用AJAX的页面获取一个特定的div,该div中包含一些Javascript,但由于某些原因Javascript无法加载。。。我只能看到HTML 我做错了什么? 这是我的代码: $.ajax({ url: 'web.php', type: 'GET', datatype: 'html', success: function (html) { var data = $('#content',$(html)).html(); YAHOO

我正在尝试从另一个使用AJAX的页面获取一个特定的div,该div中包含一些Javascript,但由于某些原因Javascript无法加载。。。我只能看到HTML

我做错了什么? 这是我的代码:

$.ajax({ url: 'web.php', type: 'GET', datatype: 'html', success: 
    function (html) { 
        var data = $('#content',$(html)).html();
        YAHOO.plugin.Dispatcher.process($('#content').get(0), data);  
    } 
});
用这个

 $.ajax({ url: 'web.php', type: 'GET', datatype: 'html', success: 
     function (html) { 
        $("script").append(html);
         var data = $('#content',$(html)).html();
         YAHOO.plugin.Dispatcher.process($('#content').get(0), data);  
     } 
 });

如果您的.js没有加载,则可能在某个地方出现语法错误,您的浏览器将使用以前缓存的版本。我会回顾我的最后几次更改,看看我弄糟了什么——缺少括号、括号、分号等。

可能会将数据类型更改为javascript或application/javascript。只是预感html变量中返回了什么?我想要一个集装箱?如果可能的话,尝试使用一个唯一的ID来处理你的目标元素。你只看到HTML是什么意思?当你运行页面时,你没有在页面中看到你的javascript?或者在您调用ajax函数之后?@Yatrix在我调用ajax之后。这可能会导致DOM膨胀
script
不应该有任何子项。如果文档包含多个
标记,来自AJAX的
脚本将执行多次。出于某种原因,当我尝试使用此脚本时,它刚刚将我的页面刷新为空白页面,我收到大量js错误调用AJAX函数。甚至连#content div都会加载所有html。但该页面上也有javascript。javascript未加载..我尝试使用此函数,但得到以下javascript错误:ReferenceError:reference to undefined XML name::[Break On this error]如果ajax函数正在工作,那不是问题所在。如果您正在注入html的页面中的javascript没有显示,那么您必须删除一个语法错误。