$ .ajax到$ getJSON

Dot*_*row -2 javascript jquery asp.net-mvc-3

我想转换以下Jquery代码使用$ .ajax intead $ .getJSON,这将是$ .ajax代码?

$(function () {
    $('#checkExists').click(function () {
     $.getJSON($(this).attr('href'), function (result) {
            alert(result);
            if (result) {
                alert('the record exists');
            }           
        });
        return false;
    });
});
Run Code Online (Sandbox Code Playgroud)

请建议

Mil*_*ric 7

$.ajax({
  url: $(this).attr('href'),
  success: function (result) { ... },
  dataType: 'json'
});
Run Code Online (Sandbox Code Playgroud)

另外,我建议使用event.preventDefault()而不是return false;