1
當試圖以JSON格式發佈表單數據,下列不工作,我注意到:
$.ajax({
type: "POST",
url: url,
data: JSON.stringify(formData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// TODO: Listen for server ok.
alert(msg);
}
但是,這個工程:
$.post(url,
JSON.stringify(formData),
function(msg) {
// TODO: Listen for server ok. If this is successfull.... clear the form
alert(msg);
},
"json");
這只是好奇心,但有誰知道爲什麼?有沒有任何理由使用這個而不是另一個?