//Getting data via Ajax
$preff = $_POST['preff'];
$input['type'] = $_POST['type'];
$input['Availability'] = $_POST['Availability'];
//get the existed data
$output = get_option($preff);
//Check if data new add it to the array, or update
When its exist
if($input['type'] != ''){
$found = false;
foreach($output as $key => $value){
if($value['type'] === $input['type']){
$output[$key] = $input;
$found = true;
}
}
if(!$found){
$output[] = $input;
}
}
//update option
var_dump(update_option($preff, $output));
我正在尝试更新选项,但始终返回false。设置Api已经使用了一些键,但是我需要在不重新加载页面的情况下动态更新数据。