How to pass an array through in JQuery Ajax and how to concieve it in server side?

I have a problem where i have to pass a list of ids to serverside to delete some users, but my requirement is to do it using JQuery Ajax. But I was not able to get the parameters in my server side can anybody give a help on this to sort out pls?

What i have done till now is shown below

  var idList = new Array();
$  (document).ready(function () {
    $  ('input:checkbox').click(function () {
        //set our checkedcount variable to 0
        var checkedCount = 0;
        //loop through and count the number of "checked" boxes
        $  ('.acceptUsers:checked').each(function () {
            //if a checked box was found, increase checkedCount by 1
            idList.push($  (this).val());
            checkedCount++;
        });
    });
});
      $  ('#btnDelete').click(function () {
          url = 'Teacher/UpdateUserStatus/';
          var ids = idList.toString();
          $  .ajax({
              type: "POST",
              url: url,
              data: { 'userIds': ids },
              contentType: "application/json; charset=utf-8",
              dataType: "html",
              success: function (data) {
                  alert('yeah');
                }
              }
          });
      });

What i have done in my server side is

    [HttpPost]
    public JsonResult UpdateUserStatus(object userIds)
    {
        List<int> usersToDelete = new JavaScriptSerializer().ConvertToType<List<int>>(userIds);
        this.userService.DeleteUsers(usersToDelete);
        return Json(true, JsonRequestBehavior.AllowGet);
    }

Can anybody know why my server side method is not calling?

newest questions tagged jquery – Stack Overflow

About Admin