[英]Ajax call html page contain JQuery
我使用Ajax加载包含jQuery函数的html页面。
页面A用ajax调用页面B。 在页面B中,生成了一些HTML,其中包含一些jquery函数。 但我认为他尝试在页面B上运行jquery。我收到错误$ is undefined
并且我的jquery源在页面A中。
我可以阻止在页面B上执行javascript吗?
这是我从A页打来的电话:
var options = {
dataType: 'html',
beforeSubmit: function () {
$('#' + s_Target_Response).animate({
opacity: 0
});
},
success: function (response) {
$("#loading").offset({ top: 1, left: 1 });
$('#loading').hide();
Init();
$('#' + s_Target_Response).html(response);
$('#' + s_Target_Response).animate({
opacity: 1
});
}
};
// pass options to ajaxForm
$('#' + s_Target_Form).ajaxForm(options);
$('#' + s_Target_Form).submit();
如果要阻止执行页面B上的脚本,请执行以下操作: 并且由于您没有在页面B上定义jQuery; 包装您的脚本
if( typeof jQuery !== 'undefined' ){
//page B scripts
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.