【发布时间】:2016-12-30 08:44:03
【问题描述】:
我有以下代码 javascript:
var configuration = [];
configuration["step 1"] = val1;
configuration["step 2"] = val2;
configuration["step 3"] = val3;
configuration["extraData"] = extra_data;
var data = {
action: 'configuration_save',
config: configuration,
};
$.post(ajaxurl, data, function (response) {
alert(response)
});
$_POST['config'] 在 PHP 中显示为空。我在传递数组时是否犯了任何错误。
PHP 代码
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
add_user_meta( $user_id, "CONFIG", $_POST['config']);
【问题讨论】:
-
在此处删除
,config: configuration, -
告诉我们
configuration_save代码 -
@TheFlash : 还是空的
-
我想看看您在发布数据后如何处理数据 - 请出示该代码
-
像这样声明新的关联数组,
var configuration = {};