简体   繁体   English

Ajax调用html页面包含JQuery

[英]Ajax call html page contain JQuery

I load an html page containing a jquery function with Ajax. 我使用Ajax加载包含jQuery函数的html页面。

Page A calls Page B with ajax. 页面A用ajax调用页面B。 In Page B, some HTML is generated and contains some jquery functions. 在页面B中,生成了一些HTML,其中包含一些jquery函数。 But I think he tries to run the jquery on page B. I get errors $ is undefined and my jquery source are in Page A. 但我认为他尝试在页面B上运行jquery。我收到错误$ is undefined并且我的jquery源在页面A中。

Can I prevent the execution of javascript on Page B? 我可以阻止在页面B上执行javascript吗?

Here is my call from Page A: 这是我从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();

If you want to prevent the execution of the script on Page B; 如果要阻止执行页面B上的脚本,请执行以下操作: and since you dont have jQuery defined on page B; 并且由于您没有在页面B上定义jQuery; Wrap your scripts in 包装您的脚本

if( typeof jQuery !== 'undefined' ){
  //page B scripts
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM