我在 php 中有一个 while 循环,它获取查询的 assoc 结果,然后将它们显示在一个类中,其中包含发布该帖子的用户的 id,我正在尝试将类的 id 发送到 php,因为我正在发送num 变量,但是我在尝试发送它时似乎遇到了 undefined index 错误。
这是我目前所拥有的-
(".eventer button[name=lol]").click(function() {
console.log('clicked');
var ida = this.id;
thisBtn = $(this);
parent = $(this).parent();
num = parent.data('num');
id = parent.data('id');
if (typeof num != 'number') {
num = 0;
$(this).attr('disabled', true);
$.post('javas.php?ida= ' + ida, {
num: (num + 1),
id: id
}, function(data) {
console.log('Ajax success');
parent.next('.status').html(data);
thisBtn.attr('disabled', false); // reset });
console.log('Ajax success');
parent.data('num', ++num);
parent.next('.status').html(data);
thisBtn.attr('disabled', false); // reset
});
});
console.log('-- end');
感谢任何帮助。
最佳答案
你应该使用:
.attr('id');
代替:
.data('id');
关于php - 使用 Jquery 发送帖子 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8692787/