WebForm下的$.ajax中contentType: 「application/json」 的用法

不使用contentType: 「application/json」則data能夠是對象node

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字符串ajax

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 });
相關文章
相關標籤/搜索