【发布时间】:2013-02-09 10:25:31
【问题描述】:
我使用下面的代码 sn-p 向服务器发送了一些数据,但我不知道如何使用 PHP 检索返回的数组。感谢您的任何建议。
$('.ticket-row').each(function() {
tickets.push({ id : $(this).attr('id'),
no : $(this).find('#no').text(),
c_name : $(this).find('#c_name').val(),
next_of_kin: $(this).find('#next_of_kin').val(),
address : $(this).find('#address').val(),
seat_no : $(this).find('#seat_no').val(),
fare : $(this).find('#fare').val() });
});
$.ajax({
type : 'POST',
url : '**URL_HERE**',
data : JSON.stringify(tickets),
dataType : 'json'
});
【问题讨论】:
-
您是否尝试过在 $_POST 中查找?
-
@thescientist 是的,我收到以下错误“json_decode() 期望参数 1 是字符串,给定数组”
-
@Chibuzo 尝试在您的 ajax 请求中设置
contentType:'application/json',。 -
你使用了正确的标签——“json-decode”,PHP函数被称为php.net/manual/en/function.json-decode.php你能告诉我们PHP部分吗?
标签: php javascript jquery json stringify