I’m using the following line to disable all checkboxes on a page:
$('input[type=checkbox]').attr('disabled', 'true');
I then want to reenable them if the ajax call succeeds, but this doesn’t seem to do it:
$.ajax({
url: 'EditService.svc/whatever',
type: 'GET',
data: { "code": code },
dataType: 'json',
success: function () {
//clear status
$('.EditStatus').html('')
//reenable all checkboxes
$('input[type=checkbox]').attr('disabled', 'false');
},
error: function (a, b, c) {
$('.EditStatus').html("Database Error!");
}
});
I don’t understand why. The //clear status portion works fine.
The string ‘true’ evaluates to true, because it’s a non-empty string, whereas ‘false’ is not falsy as it is not empty. Try:
and while this works:
You should still pass a boolean instead of a string.
If you are using jQuery 1.6+, you should use
.prop(and.removeProp) instead.