简体   繁体   English

jQuery(JavaScript)刷新div

[英]jquery (javascript) refresh div

Bear with me. 忍受我。 I recently started implementing jquery at work. 我最近开始在工作中实现jquery。 I created a new app already so I do have an understanding of what goes but I have not fully grasped it yet. 我已经创建了一个新的应用程序,因此我对运行情况有所了解,但是我还没有完全掌握它。

I have this function below that is being called everytime someone clicks a checkbox in a table wrapped in a unique div id. 每当有人单击包含唯一div ID的表中的复选框时,都会调用此函数。 Currently, the table does not refresh until you close the dialog box. 当前,在关闭对话框之前,该表不会刷新。 I want the div to refresh after the the server finishes its request. 我希望div在服务器完成其请求后刷新。

I got it to work only for the first row in the table by simply calling the displayMid function again (that is commented out in the code below). 通过再次调用displayMid函数(在下面的代码中将其注释掉),我只能在表的第一行使用它。

How do I get this to work for all the table rows? 如何使它适用于所有表行? You can see I have been trying a few things already. 您可以看到我已经尝试了一些事情。 ;-) ;-)

Any help is appreciated! 任何帮助表示赞赏! Thanks! 谢谢!

function addRemoveMid(count, testpid) {
        var x = testpid;
        var y = $("#Mid" + count).text();
        var a = $("#midcheckbox" + count).is(':checked');
        //alert(x);
        if (!$("#midcheckbox" + count).is(':checked')) {
            $.ajax({
                url: "content_backend_pub_pid.ashx",
                data: { cmd: '10', pid: x, mid: y },
                type: "get",
                async: false,
                success: function(o) {
                    //displayMid(count);
                    //$("#inputDiv4").replaceWith($('#inputDiv4', $(html)));
                }
            });
            //$(this.addRemoveMid(count);
        }
        else {
            $.ajax({
                url: "content_backend_pub_pid.ashx",
                data: { cmd: '9', pid: x, mid: y },
                type: "get",
                async: false,
                success: function(o) {
                    //displayMid(count);
                    //$("#inputDiv4").replaceWith($('#inputDiv4', $(html)));
                }
            });
            //displayMid(count);
        }
        //$("#inputDiv4").fadeOut("fast").html('reload.php').fadeIn("fast");
    }

'Currently, the table does not refresh until you close the dialog box' what this means? “当前,在关闭对话框之前,表不会刷新”这是什么意思? I see only a commented alert(x).What dialog box are you talking about? 我只看到注释的警报(x)。您在说什么对话框?

Plans changed and my boss said he would rather have it refresh on close. 计划改变了,我的老板说他宁愿收盘刷新。 So it is fine the way it is. 所以这是很好的。

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

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