jQuery $.post to PHP and get back in JSON format
Based on this answer trying to modify jQuery to send data to PHP and get
back in JSON format.
Created this
$.post(
"__02.php",
{
'date_day': date_day,
'currency': currency
},
function (data, textStatus) {
$('#currency_load').html(data);
$('#is_row_changed_currency' + suffix).val(0)
},
"json"
);
PHP is like this
$arr = array ('item1'=>"I love jquery4u",'item2'=>"You love
jQuery4u",'item3'=>"We love jQuery4u");
echo json_encode($arr);
But does not work. What need to correct?
For comparison without JSON this works:
$.post("__02.php", { 'date_day': date_day, 'currency': currency },
function(data) {
$('#currency_load').html(data);
$('#is_row_changed_currency' + suffix).val(0)
});
No comments:
Post a Comment