jQuery ajax contentType vs dataType

閱讀時間約 1 分鐘
$.ajax({
url: "data.php",
type: "post",
data: {"test": "hello"},
dataType: "json",
contentType : 'application/json; charset=utf-8',
success: function(data) {
console.log(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
}
});
contentType是用來定義送到server的資料型態
dataType是用來定義從server回傳要接收的資料型態
為什麼會看到廣告
20會員
161內容數
留言0
查看全部
發表第一個留言支持創作者!