Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.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
Javascript 调用脚本文件中的第二个函数_Javascript_Php - Fatal编程技术网

Javascript 调用脚本文件中的第二个函数

Javascript 调用脚本文件中的第二个函数,javascript,php,Javascript,Php,所有Ajax选择框填充效果都很好。现在我想从(a href=“”)标记触发Ajax脚本。但该函数不会像这样触发: jQuery(document).ready(function() { CustomerBoxesLoad.init(); }); 这个对JavaScript的引用不起作用 在报税表中添加另一个函数: a href="javascript:handleAjaxBoxesSelectedCountry();">Refresh Sel

所有Ajax选择框填充效果都很好。现在我想从(a href=“”)标记触发Ajax脚本。但该函数不会像这样触发:

    jQuery(document).ready(function() {    
        CustomerBoxesLoad.init();   
    });

这个对JavaScript的引用不起作用

在报税表中添加另一个函数:

a href="javascript:handleAjaxBoxesSelectedCountry();">Refresh Select Box
和“a”标签:

 return {
    //main function to initiate the module
    init: function () {
        handleAjaxBoxesSelectedCountry();
        handleAjaxBoxesCustomerType();
    }

    handleAjaxBoxesSelectedCountry: function () {
        handleAjaxBoxesSelectedCountry();
    }
};

我自己解决了:

<a href="javascript:CustomerBoxesLoad().init();return false;">STH</a>

在全局范围内创建一个将调用您的方法的包装器函数,并改用该函数。我不想使用CustomerBox()事件。我需要调用此函数“handleAjaxBoxesSelectedCountry()”中的子函数。根据您的代码,“CustomerBoxesLoad”是您声明的函数,它返回一个包含另一个名为“init”的函数的类/对象。因此,要在函数“CustomerBoxesLoad”的返回中调用init函数,我们需要首先调用此函数,然后从返回的对象调用init函数。请理解CustomerBoxesLoad函数在窗口加载事件中起作用。没问题。现在,我正在寻找一种在javascript文件中重新加载函数“handleAjaxBoxesSelectedCountry”的方法。
<a href="javascript:CustomerBoxesLoad().init();return false;">STH</a>
return {

    //main function to initiate the module
    init: function () {

        handleAjaxBoxesCountry();
        handleAjaxBoxesCustomerType();

    },
    init_country: function () {
        handleAjaxBoxesCountry();
    },
    init_type: function () {
        handleAjaxBoxesCustomerType();
    }       

};