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 () {

            }
        })

 

你可能感兴趣的:(WebAPI AJAX写法)