开发者

$.ajax to $getJSON

开发者 https://www.devze.com 2023-03-19 04:43 出处:网络
I want to convert following Jquery code to use $.ajax intead of $.getJSON, what will be $.ajax code for this?

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

精彩评论

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