對象解析AJAX GET方法我感謝你說你對這個misterious行爲的意見:的Jquery在JSON
此代碼的工作:
JS代碼:
$.ajax({
url: "ajouterEntreeParExcel.ajax.php", // url de la page à charger
data: {"name":"John","date":"05 & 06 mars"},
cache: false, // pas de mise en cache
async: false,
contentType : "application/json",
dataType: "json",
success:function(jsonRetour){
},
error:function(XMLHttpRequest, textStatus, errorThrows){ // erreur durant la requete
}
});
和PHP代碼:
$name = $_GET["nom"];
$date = $_GET["date"];
而這一次不起作用
var dataAjax = {};
dataAjax["name"] = "John";
dataAjax["date"] = "05 & 06 mars";
var entree = JSON.stringify(dataAjax);
$.ajax({
url: "ajouterEntreeParExcel.ajax.php", // url de la page à charger
data: entree,
cache: false, // pas de mise en cache
async: false,
contentType : "application/json",
dataType: "json",
success:function(jsonRetour){
},
error:function(XMLHttpRequest, textStatus, errorThrows){ // erreur durant la requete
}
});
具有相同的PHP代碼。 在調試與螢火蟲,我檢查變量「主菜」,這是很好的格式化,但我沒有得到任何東西在PHP方面。
nota:我喜歡使用GET類型而不是POST類型。
有什麼想法?
永遠不要使用'async:false'!這是一種可怕的做法,現在已棄用 – charlietfl