$.ajax to $getJSON
I want to convert following Jquery code to use $.ajax intead of $.getJSON, what will be $.ajax code for this?
$(function () {
$('#checkExists').click(function () {
$.getJSON($(this).attr('href'), function (result) {
ale开发者_StackOverflowrt(result);
if (result) {
alert('the record exists');
}
});
return false;
});
});
Please suggest
$.ajax({
url: $(this).attr('href'),
success: function (result) { ... },
dataType: 'json'
});
Also, I'd suggest using event.preventDefault()
instead of return false;
精彩评论