WebForm下的$.ajax中contentType: “application/json” 的用法

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

1 $.ajax({
2 url: actionurl,
3 type: "POST",
4 datType: "JSON",
5 data: { id: nodeId },
6 async: false,
7 success: function () {}
8 });

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

1 $.ajax({
2 url: actionurl,
3 type: "POST",
4 datType: "JSON",
5 contentType: "application/json"
6 data: "{'id': " + nodeId +"}",
7 async: false,
8 success: function () {}
9 });

 

 
posted @ 2017-10-17 14:05  哪啊哪啊神去村  阅读(364)  评论(0编辑  收藏  举报