$.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回傳要接收的資料型態