WebAPI AJAX写法

1、

$(function () {
        var dataJSON = {Id:1,Title:'标题测试'};
        console.log(JSON.stringify(dataJSON));
        $.ajax({
            url: "http://localhost:53620/api/values",
            type: "Post",
            data: JSON.stringify(dataJSON),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function () {

            }
        })
    })

2、

$.ajax({
            url: "http://localhost:53620/api/values",
            type: "Post",
            data: { Id: 1, Title: '标题测试' },
            success: function () {

            }
        })

 

posted on 2020-02-06 23:45  静以修身俭以养德  阅读(330)  评论(0编辑  收藏  举报

导航