写法如下:
$('#save').click(function() { var t = { "createTime":"2016-01-13 01:01:01","name":"bbbbbbbbb" } $._ajax({ type:'post',url:basePath + '/api/test/save.action',data:JSON.stringify(t),//将对象转为为json字符串 dataType:"json",contentType:"application/json",//这个必须,不然后台接受时会出现乱码现象 success:function(data){ if(data.result){ alert("成功了"); }else{ alert("失败了"); } },error:function(){ alert("出错了"); } }); });原文链接:https://www.f2er.com/ajax/162513.html