call action method on checkbox click asp.net mvc without pageload code example
Example: call action method on checkbox click asp.net mvc without pageload
@section scripts {
<script>
$(function() {
$('.toggle').change(function() {
var self = $(this);
var url = self.data('url');
var id = self.attr('id');
var value = self.prop('checked');
$.ajax({
url: url,
data: { id: id },
type: 'POST',
success: function(response) {
alert(response);
}
});
});
});
</script>
}