Answer the question
In order to leave comments, you need to log in
Bad request in POST ajax Wordpress. How to fix?
Part of JS code:
jQuery( "#edit_dialog" ).dialog({
title: "Редактирование услуги",
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
"Сохранить изменения": function() {
var upd_servise_label = jQuery('#upd_servise_label').val();
var upd_servise_cost = jQuery('#upd_servise_cost').val();
var servise_data = {
'action': "edit_servise",
'servise_id' : servise_id,
'current_servise_key' : current_servise_key,
'current_servise_label' : current_servise_label,
'current_servise_cost' : current_servise_cost,
'upd_servise_label' : upd_servise_label,
'upd_servise_cost' : upd_servise_cost,
};
jQuery.ajax({
type:"POST",
url: ajaxurl,
dataType: 'json',
data: "data="+JSON.stringify(servise_data),
success:function(data){ console.log(data); },
error: function(errorThrown){ console.log(errorThrown); }
});
},
"Отмена": function() { jQuery( this ).dialog( "close" ); }
}
});
if($_POST['data']) {
$data = json_decode($_POST['data']);
$servise_id = get_text($data->servise_id);
echo json_encode($servise_id);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question