表单位于“创建后”窗口中。Ajax正在发布值,但这些值不会更新。问题出在哪里?
AJAX
<script>
function dynamic_Select(field, aid, value)
{
console.log(field, aid,value);
jQuery.ajax({
type: "POST",
url: ajaxurl,
data:{
field: field,
aid: aid,
value: value,
},
error: function(){alert(\'Error!\')},
success: function(){alert(value)}
});
}
</script>
功能。php
add_action(\'wp_ajax_dynselect\', \'update_dynamic_select\');
add_filter("attachment_fields_to_save", " update_dynamic_select", null , 2);
function update_dynamic_select($field, $aid, $value) {
update_post_meta($aid, $field, $value);
}
HTML:
<select aid="104" name="_image_matmenys" onchange="dynamic_Select(this.getAttribute(\'name\'), this.getAttribute(\'aid\') ,this.value)">
<option value="10x10">10x10</option>
<option value="20x20" selected="selected">20x20</option>
<option value="30x30">30x30</option>
</select>