开发者

$.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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜