[英]Error with ajax request POST
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: 我更改了数据,当我按Enter键时,该数据应该发送到update_cell.php文件,但是当我输出它时,
example echo $ _POST ["id "]
我得到了错误提示:
Undefined index: id in W: \\ domains \\ test \\ wp-content \\ plugins \\ related-equipment \\ includes \\ update_cell.php on line 2
未定义的索引:W中的ID:\\ domains \\ test \\ wp-content \\ plugins \\ related-equipment \\ includes \\ update_cell.php第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 : 您需要使用post方法传递这样的数据:
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
然后,您可以使用
$_POST[key]
在服务器端获取值之后,此处的key
将是value
, id
,您通过ajax
传递的field
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.