I want get data from php with jquery.I wrote this code:
<?php
$return=array('content'=>1,'id'=>2,'priority'=>3);
echo json_encode($return);
?>
in jquery:
$.ajax({
type:'post',
url:'next_prev.php',
data:{act:act,id:id,priority:priority},
dataType: 'json',
cache: false,
success:function(data){
var obj=jQuery.parseJSON(data)
$('#content').html(obj.content);
$('#priority').html(obj.priority);
$('#id').html(obj.id);
},
});
but it does not work.whats wrong?
Thanks
data in the success callback is formatted according to dataType, i.e. no need to parseJSON it again
try to remove
var obj=jQuery.parseJSON(data)and usedata.contentdata.priorityetc directly