Php 使用POST jquery发送数组(对象)

Php 使用POST jquery发送数组(对象),php,jquery,ajax,json,Php,Jquery,Ajax,Json,或者 警报数据正在输出一个对象(对象)。我正在寻找一个堆栈溢出,但它仍然不起作用。从不调用警报(responseText)。您是否尝试在jQuery Ajax API中将内容类型指定为“application/json”,然后调用 stringify(数据) 另外,在Google Chrome浏览器中打开web开发者控制台,导航到网络选项卡,查看Ajax调用过程中发生的情况。i、 e.在Ajax调用中发送什么数据和接收什么数据。您是否尝试过序列化?它汇总了所有表单数据。这似乎就是您试图对数据对象

或者


警报数据正在输出一个对象(对象)。我正在寻找一个堆栈溢出,但它仍然不起作用。从不调用警报(responseText)。

您是否尝试在jQuery Ajax API中将内容类型指定为
“application/json”
,然后调用

stringify(数据)


另外,在Google Chrome浏览器中打开web开发者控制台,导航到网络选项卡,查看Ajax调用过程中发生的情况。i、 e.在Ajax调用中发送什么数据和接收什么数据。

您是否尝试过
序列化?它汇总了所有表单数据。这似乎就是您试图对
数据
对象执行的操作

$.post("api/update_prices.php", data, function (responseText) {
    alert(responseText);
});

您的$.post函数应该如下所示:

$.post("api/update_prices.php", $(':input').serialize(), function (responseText) {
    alert(responseText);
});

请注意JSON.stringify

您的第二个代码片段应该可以工作。隔离代码并尝试查找问题。如果您在safari/chrome/firefox上,请使用console.log()在javascript控制台的帮助下检查对象。
$.post("api/update_prices.php", $(':input').serialize(), function (responseText) {
    alert(responseText);
});
$.post("api/update_prices.php", {'data[]': JSON.stringify(data)}, function (responseText)  {
    alert(responseText);
});