jquery post json data to PHP file -


i have click event compose json data, want post php file processing. goes wrong. php file simplified looking this:

<?php header('content-type: application/json');  var_dump($_post); ?> 

and code post-ing looks this:

// myarray is: var myarray = new array();  // , gets populated above code  var strobj = json.stringify(myarray); alert(strobj); // far alert containing valid json text $.ajax ({   type:"post",   url:"proces.php",   contenttype: "application/json",   datatype: "json",   async: false,   data: strobj,   success: function(){ alert("success")},   error: function(){ alert("error")} }); 

so when click button, receive alert containing json string (looks fine), alert saying "error", , when check console response of proces.php see is:

array(0) { } 

what doing wrong? can make right?

this did trick me:

$.ajax ({   type:"post",   url:"proces.php",   datatype: "json",   async: false,   data: {tmp: strobj},   success: function(){ alert("success")},   error: function(){ alert("error")} }); 

Comments