在jquery中部分使用$ .post()重新加载页面 [英] Page reloading partially using $.post() in jquery

查看:420
本文介绍了在jquery中部分使用$ .post()重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://twillsonline.in/shirts-2 在此链接中,我尝试使用jquery调用返回jsonresult的操作发布方法。第一次页面加载当我试图选中复选框时,我收到结果但复选框取消选中..任何机构都可以解决此问题。

http://twillsonline.in/shirts-2 In this link i have tried to call action which returns jsonresult using jquery post method. First time of page load when i am trying to select check box i am getting result but check box gets uncheck .. any body can fix this issue.

$.post('@Url.Action("Action", "Controller")', { parameter:value }, function (data) {

            if (data != null && data.trim() != "") {
                $('#div').html(data);
            }
            else {
                $("#div").html(" No Results Found ");
            }
        });



是我调用动作的代码返回jsonresult




here is my code for calling action which returns jsonresult

function sort() {
             
            var param = "";
            var innerCheckbox = $(this).find(':checkbox');
            var check1 = $("#namlist-size").parent().find(':checkbox:checked').map(function () { return this.value; }).get();
           



                

                for (var i = 0; i < check1.length; i++) {
                    param = param + check1[i] + ",";
                }

                param = param.substring(0, param.length - 1);

                $.post('@Url.Action("Action","Controller")',{parameter:value} function (data) {

                    jQuery('html, body').animate({ scrollTop: 0 }, 500);

                    if (data != null && data.trim() != "") {
                         
                        data = data.toLowerCase();
                        $('div .page-body').html(data);
                        var replaced = $('div .page-body').html().replace(/\Rs/g, "<del>&#2352;</del> ");
                        $('div .page-body').html(replaced);
                    }
                    else {
                        $("div .page-body").html("<h1 style='color:red;' >No Results Found</h1>");
                    }
                });
           
        }

推荐答案

.post(' @ Url.Action(Action,Controller)',{parameter:value}, function (data){

if (data!= null && data.trim()!= ){
.post('@Url.Action("Action", "Controller")', { parameter:value }, function (data) { if (data != null && data.trim() != "") {


' #div' )HTML(数据)。
}
else {
('#div').html(data); } else {


#div)。html( 没有结果找到);
}
});
("#div").html(" No Results Found "); } });



这是我调用动作的代码,返回jsonresult




here is my code for calling action which returns jsonresult

function sort() {
             
            var param = "";
            var innerCheckbox =


这篇关于在jquery中部分使用$ .post()重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆