I have some problems with request to file. I have to edit the data in the table created in the plugin. When I click on the text, I create an input. I change the data and when I press the enter key this data should be sent to the update_cell.php file but when I output it for example echo $ _POST ["id "]
I get the error Notice:
Undefined index: id in W: \ domains \ test \ wp-content \ plugins \ related-equipment \ includes \ update_cell.php on line 2
Is it possible my path is incorrectly specified? Although I propps it as absolute. I think problems should not be
jQuery(document).ready(function($){
$('td.edit').click(function(){
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
$(this).addClass('ajax');
$(this).html('<input id="editbox" size="'+ $(this).text().length+'" type="text" value="' + $(this).text() + '" />');
$('#editbox').focus();
});
//UPDATE TABLE
$('td.edit').keydown(function(event){
eq_arr = $(this).attr('class').split( " " );
if(event.which == 13)
{
var table = $('table').attr('id');
$.ajax({ type: "POST",
url:"http://test/wp-content/plugins/related-equipment/includes/update_cell.php",
data: "value="+jQuery('.ajax input').val()+"&id="+eq_arr[1]+"&field="+eq_arr[2]+"&table=gc-equip",
success: function(data){
console.log(this);
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
}});
}});
$(document).on('blur', '#editbox', function(){
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
});
});
You need to pass data like this with post method :
data : {
value: jQuery('.ajax input').val(),
id: eq_arr[1],
field: eq_arr[2]
// and so on
}
Then after you can get the values at server side using $_POST[key]
here key
will be value
, id
, field
that you passed via ajax