$.ajax中contentType: “application/json” 的用法[转]

[转http://blog.csdn.net/calyxmelo/article/details/54969244

不使用contentType: “application/json”则data可以是对象

$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
data: { id: nodeId },
async: false,
success: function () {}
});

 

使用contentType: “application/json”则data只能是json字符串

$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
contentType: "application/json"
data: "{'id': " + nodeId +"}",
async: false,
success: function () {}
});
posted on 2017-03-29 09:24  陈-chen  阅读(356)  评论(0编辑  收藏  举报