1

How to change this in ajax call. This is the jquery code which is calling the controller and getting the data from the database and onclick of checkbox filtering of data is happening and displaying the resulted data. Now my my requirement is do this thing with ajax call. How should I do.

$('input[name^="checkbox_"]').click(function () {
    $('#checkbox_all').prop('checked', false);
    var Status = $(this).val();
    if (Status == 'allocated') {
        var url = "statusAdmin.html?Status=" + Status;
        $(location).attr('href', url);
    }
});
Rikard
  • 7,485
  • 11
  • 55
  • 92
  • Possible duplicate of [Event binding on dynamically created elements?](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – Bhojendra Rauniyar Nov 24 '15 at 05:19

1 Answers1

1

To make the same with Ajax you need to change the logic like this:

$('input[name^="checkbox_"]').click(function () {
    $('#checkbox_all').prop('checked', false);
    var status = this.value;
    $.ajax({
        url: "statusAdmin.html?Status=" + status,
        success: function (res) {
            //do something with the response
        }
    });
});
Rikard
  • 7,485
  • 11
  • 55
  • 92