【发布时间】:2017-01-25 20:35:22
【问题描述】:
我有一个数组,从一些输入值得到一个像这样的 jQuery
var ingredient = [];
text.each(function(){
ingredient.push($(this).val());
});
并像这样使用ajax发送
$.ajax({
url: "update_recipe.php",
type: "post",
data: ingredient,
dataType: "html",
success : function(code_html, statut){
console.log(code_html);
console.log(statut);
},
error : function(resultat, statut, erreur){
console.log("La requête n'a pas aboutie...");
console.log(resultat);
console.log(statut);
console.log(erreur);
}
});
但是当我需要使用 php 获取数组时,$_POST 为 NULL...
你知道我该如何发送这个数组吗?
谢谢
【问题讨论】:
-
显示你的php代码,用
console.log检查ingredient的值 -
console.log 的数组类似于 ["2 oeufs", "125 g de farine", "25 cl de lait", "1/2 cuillère à café de sucre", " 1 cc de levure chimique”、“30 g de beurre fonda”、“1/2 cc de sel”、“1 cs d'eau de fleur d'oranger”] 而 php 只是 var_dump($_POST)
标签: php jquery arrays ajax serialization