function postSimpleData() {
$.ajax({
type: "POST",
url: "/Service/SimpleData",
contentType: "application/json", //必须有
dataType: "json", //表示返回值类型,不必须
data: JSON.stringify({ 'foo': 'foovalue', 'bar': 'barvalue' }), //相当于 //data: "{'str1':'foovalue', 'str2':'barvalue'}",
success: function (jsonResult) {
alert(jsonResult);
}
});
}
function postListString() {
$.ajax({
type: "POST",
url: "/Service/ListString",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({ "BuIds": ["1", "2", "3"] }),
success: function (jsonResult) {
alert(jsonResult);
}
});
}
function postEmployees() {
$.ajax({
type: "POST",
url: "/Service/Employees",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
"Employees": [
{ "firstName": "Bill", "lastName": "Gates" },
{ "firstName": "George", "lastName": "Bush" },
{ "firstName": "Thomas", "lastName": "Carter" }
]
}),
success: function (jsonResult) {
alert(jsonResult);
}
});
}