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/0/asp.net-mvc/14.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
net中的链式jqueryajax函数和普通函数_Jquery_Asp.net Mvc - Fatal编程技术网

net中的链式jqueryajax函数和普通函数

net中的链式jqueryajax函数和普通函数,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我有一个函数YR.printGraphs()。这将执行大量ajax调用并绘制图形 在完成所有ajax调用后,我必须执行一些脚本,但我不能这样做。我尝试了下面的方法,也延迟了我似乎没有任何东西能奏效的方式 “sangeetha”功能从不启动。我做错了什么 $("#pnlEmail1").ready(function () { YR.printGraphs(); }).sangeetha(); function sangeetha() { var s = 0.0; $(".

我有一个函数YR.printGraphs()。这将执行大量ajax调用并绘制图形

在完成所有ajax调用后,我必须执行一些脚本,但我不能这样做。我尝试了下面的方法,也延迟了我似乎没有任何东西能奏效的方式

“sangeetha”功能从不启动。我做错了什么

$("#pnlEmail1").ready(function () {
    YR.printGraphs();
}).sangeetha();

function sangeetha() {
    var s = 0.0;
    $(".printgraphs").each(function () {
        s += parseFloat($(this).height());
    });

    s = s - parseFloat($("#pnlEmail1").height());

    $(".fulldtls").css({ "top": s + "px", "position": "relative" });
}

printGraphs: function () {
        ///<summary>Loop through the email metrics available for this customer and makes ajax calls to get the email graph data.</summary>
        $(".printgraphs").each(function () {

            //Every div id is generated with its respective tab name in printreport.cs to distingush graphs.
            // So, check if the div belongs to Email tab, Phone tab or Grades and send the respective tab name to controller to get the correct graph data.
            if ($(this).attr("id").toLowerCase().indexOf("email") >= 0) {
                YAHOO.Report.changeGraph("Email", $(this), true);
            }
            else if ($(this).attr("id").toLowerCase().indexOf("grade") >= 0) {
                YAHOO.Report.changeGraph("Grades", $(this), true);
            }
            else {
                YAHOO.Report.changeGraph("Phone", $(this), true);
            }
        });
     }
$(“#pnlEmail1”).ready(函数(){
年印刷图();
}).sangeetha();
函数sangeetha(){
var s=0.0;
$(“.printgraphs”)。每个(函数(){
s+=parseFloat($(this.height());
});
s=s-parseFloat($(“#pnlEmail1”).height();
$(“.fulldtls”).css({“top”:s+“px”,“position”:“relative”});
}
printGraphs:函数(){
///循环查看此客户可用的电子邮件指标,并进行ajax调用以获取电子邮件图数据。
$(“.printgraphs”)。每个(函数(){
//每个div id都在printreport.cs中生成,并使用其各自的选项卡名来区分图形。
//因此,检查div是否属于Email选项卡、Phone选项卡或Grades,并将相应的选项卡名称发送给controller以获取正确的图形数据。
if($(this.attr(“id”).toLowerCase().indexOf(“email”)>=0){
YAHOO.Report.changeGraph(“Email”,$(此),true);
}
else if($(this.attr(“id”).toLowerCase().indexOf(“grade”)>=0){
YAHOO.Report.changeGraph(“Grades”,$(this),true);
}
否则{
YAHOO.Report.changeGraph(“Phone”,$(这个),true);
}
});
}

每个YAHOO.Report.changeGraph都会调用ajax。我在jQuery中听说过函数链接,但不确定如何在这种情况下应用它。

ready处理程序应该只绑定到文档,即使使用您的语法,它也会工作,但可能不像您预期的那样,在DOM就绪时启动,而不是在您的元素“就绪”时启动(这无论如何没有多大意义)。您正在jquery对象上使用sangeetha()方法,而jquery对象没有这样的方法
sangeetha()
是一个函数(全局范围?),要调用它,请使用:
sangeetha()如果我直接调用sangeetha(),我不会得到所有图形的高度。我只是在所有ajax调用完成后才知道。我不知道如何调用sangeetha()函数。不能链接常规函数,只能链接使用
$声明的函数。fn.functionName=function(){…
可以这样链接。一旦ajax调用完成,您必须以常规方式执行函数,但不知道
YAHOO.Report
返回的是什么,很难说具体怎么做。是的,正如@adeneo所说,您可以检查返回的
YAHOO.Report.changeGraph()
?我的意思是:
console.log(YAHOO.Report.changeGraph());
它不返回任何内容,它具有绘制图形的ajax成功函数