我有一个JS脚本以下数据:如何将我的ajax数据导入到php数组中?
$("#holdSave").live('click', function() {
var arr = {};
var cnt = 0;
$('#holdTable tbody tr').each(function() {
arr[cnt] = {
buyer: $(this).find('#tableBuyer').html(),
sku: $(this).find('#tableSku').html(),
isbn: $(this).find('#tableISBN').html(),
cost: $(this).find('#tableCost').val(),
csmt: $(this).find('#tableConsignment').val(),
hold: $(this).find('#tableHold').val()
};
cnt++;
}); //end of holdtable tbody function
console.log(arr);
$.ajax({
type: "POST",
url: "holdSave.php",
dataType: "json",
data: {
data: arr
},
success: function (data) {
} // end of success function
}); // end of ajax call
}); // end of holdSave event
我需要发送给PHP文件更新数据库,并通过电子邮件发送的更新已完成。我的console.log(arr);当我在萤火虫中运行它时显示了这些对象,但我无法获得任何关于php的信息。这里是我的php代码:
$data = $_POST['data'];
print_r($data); die;
在这一点上,我只是想验证有信息被发送过来。我的print_r($ data);什么也不返回 任何人都可以指向正确的方向吗?
检索使用适当的工具。在这种情况下,Firebug,fiddler2,Developer Tools等,然后监视网络请求。然后,如果*有*什么发送,简化问题*仅*相关的PHP的东西,处理标题和职位*什么*发送。 – 2012-07-16 18:12:53