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 });
 
原文地址:https://www.cnblogs.com/yangwujun/p/7681337.html