asp.net mvc 3 - How to check checkbox for only checked item on jquery success function -


as need check items has value true controller on jquery success function.

<script type="text/javascript">      $("#pid").change(function ()           {             $.ajax({             url: '@url.action("getcheckedchannel","channels")',             type: 'post',             data: { pid: $(this).val() },             success: function (data) {                     (var = 0; < data.length; i++)                      {                        //if (data[i].ischecked == "1") {                        var status = data[i].ischecked ? true : false;                        $(".ischeck").attr("checked", status);                       //}                      }             }       });     }); </script> 

you can write this

data[i].ischecked ? $(".ischeck").prop("checked", true) : ''; 

also consider using .prop instead of .attr set checked property


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -