ajax - Decode JSON POST in php -


i using datatype:'json' , data: {'post':val} in ajax send data php file. val in data: {'post':val} variable.
data sent php file [object object] so, before assigning php variable, need decode it. new json , don't know much.
tried $id=$_post['post']; doesn't work since sent data in json format.
how send 'normal' data or decode data whithout removing datatype:'json' php file has array sent ajax json_encode

note: value assigned when in ajax. (when alert alert({post:val}['post']); result shown assigned).

hmm .. here updated ajax (i accidentally posted wrong 1 in previous code):-

function op_prof(obj) {     var xval = obj.id;     var datastring = "{'u_search':'"+xval+"'}";      $.ajax({     type: "post",     url: '/script/profile.php',     data: datastring,     datatype: 'json',     cache: false,     success: function(data) {         console.log(data);     }   }); }; 

datatype specifies the type of data you're expecting back server. not cause data sent json.

if data being set php program [object object] causing object stringified , put in data sent. haven't shared sufficient code determine that is.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -