I have an 2d array, with name data_forms, now i need to pass this array as object to row.php... how i can do that?
in row.php Im try to print print_r($_POST);
and output is undefind, also if i try
print_r(json_decode($_POST));
this will give me Warning: json_decode() expects parameter 1 to be string
$(".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(){
}
});
});
thanks for help
Im found a problem, Im change this data:data_forms
to data:{mydata: data_forms} also Im remove dataType:JSON
after im do that, ajax page work fine ... thanks alot for all