$.ajax中contentType: “application/json” 的用法
阿新 • • 發佈:2019-01-27
不使用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 () {}
});