D
divya
The below code works fine but I am facing an issue like the check/
uncheck event doesnot fire imediately when the user checks/unchecks
the checkbox. but fires only when after clicks outside anywhere on the
page after he changes the checkbox selection.
Please advice on what can I cahnge inorder to make it fire immediately
when user changes the checkbox in below code:
$(document).ready(function() {
var pselect = "L";
$("#pLevel").change(function() {
if ($("#pLevel").is(":checked")) {
pselect = "P";
}
else {
pselect = "L";
}
$.ajax({
url: '<%= Url.AbsoluteAction("List", "abc") %>',
type: 'POST',
data: { val: pselect },
dataType: 'json',
error: function(request, status, errorThrown) {
alert('Error retreiving list:\n' + status);
},
success: function(result) {
document.getElementById("ListSelect").options.length = 0;
$.each(result, function(i, n) {
var item = result[0];
var item2 = result[1];
$("#ListSelect").append($("<option></
option>").val(item).html(item2));
});
}
});
});
});
uncheck event doesnot fire imediately when the user checks/unchecks
the checkbox. but fires only when after clicks outside anywhere on the
page after he changes the checkbox selection.
Please advice on what can I cahnge inorder to make it fire immediately
when user changes the checkbox in below code:
$(document).ready(function() {
var pselect = "L";
$("#pLevel").change(function() {
if ($("#pLevel").is(":checked")) {
pselect = "P";
}
else {
pselect = "L";
}
$.ajax({
url: '<%= Url.AbsoluteAction("List", "abc") %>',
type: 'POST',
data: { val: pselect },
dataType: 'json',
error: function(request, status, errorThrown) {
alert('Error retreiving list:\n' + status);
},
success: function(result) {
document.getElementById("ListSelect").options.length = 0;
$.each(result, function(i, n) {
var item = result[0];
var item2 = result[1];
$("#ListSelect").append($("<option></
option>").val(item).html(item2));
});
}
});
});
});