Click here to Skip to main content
15,071,581 members
Please Sign up or sign in to vote.
4.29/5 (3 votes)
See more:
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.
JavaScript
$.post('@Url.Action("Action", "Controller")', { parameter:value }, function (data) {

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

here is my code for calling action which returns jsonresult

C#
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>");
                    }
                });
           
        }
Posted
Updated 14-Jan-14 20:39pm
v7
Comments
Sampath Lokuge 15-Jan-14 2:35am
   
Where is the code for check boxes ? Please put that code snippet also.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900