spring mvc怎么ajax post json数据
1个回答
展开全部
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 login(){
$.ajax({
url: "Service/login",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
MachineIP:"127.0.0.1",
AppTag:"4",
RequestInfo:{
StaffCode:"",
Password:"",
StaffCard:"01411"
},
}),
async: true,
success: function(data) {
var ss = JSON.stringify(data);
$("#result").val(ss);
console.log(ss);
}
contentType: "application/json", //必须有
dataType: "json", //表示返回值类型,不必须
data: JSON.stringify({ 'foo': 'foovalue', 'bar': 'barvalue' }), //相当于 //data: "{'str1':'foovalue', 'str2':'barvalue'}",
success: function (jsonResult) {
alert(jsonResult);
}
});
}
function login(){
$.ajax({
url: "Service/login",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
MachineIP:"127.0.0.1",
AppTag:"4",
RequestInfo:{
StaffCode:"",
Password:"",
StaffCard:"01411"
},
}),
async: true,
success: function(data) {
var ss = JSON.stringify(data);
$("#result").val(ss);
console.log(ss);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询