我有一个名为data_forms的二维数组,现在我需要将此数组作为对象传递给row.php ...我该怎么做?
在row.php中的我尝试打印print_r($_POST);
并且输出是unfind,如果我尝试
print_r(json_decode($_POST));
这会给我警告:json_decode()期望参数1为字符串
$(".saveNewRow").click(function(){
var number_of_row_and_clmn = parseInt($(".row_count_value").val());
var data_forms = new Array();
// all lenght are equal so we used just one
var array_2d_length = $('.row-font-style-1 .form-1').length;
for(var i = 0; i< number_of_row_and_clmn; i++){
data_forms[i] = new Array();
if($(".row-font-style-"+i).hasClass("its_div")){
data_forms[i][0] = "div";
}else{
data_forms[i][0] = "tr";
}
for(var j = 1; j <= array_2d_length; j++){
data_forms[i][j] = $(".row-font-style-"+(i+1)+" .field-"+(j-1)).val();
}
}
$.ajax ({
url:"row.php",
type:"post",
data:data_forms,
dataType:JSON,
statusCode:{
404:function(){
$("#output_data").html("page not found!!");
}},
success:function (data) {
$("#output_data").html(data);
},
complete:function(){
}
});
});
感谢您的帮助
我发现了一个问题,
我将此 data:data_forms
更改为数据:{mydata:data_forms}
也是我删除 dataType:JSON
在我这样做之后,ajax页面工作正常...非常感谢