jQuery .click未运行 [英] jQuery .click not running
本文介绍了jQuery .click未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Stackers
点击CLICK动作时遇到问题.它只是不起作用,它不运行Click.单击时,它什么都不做.甚至没有返回错误.单击是否错误?
I'm having a problem with a CLICK action. It just doesn't work, it doesn't run the Click. When Clicking, it just does nothing. Not even returning an Error. Is the Click wrong?
$( document ).ready(function() {
console.log("notclicked");
$("#makesee-<?php echo $n['id']; ?>").click(function()
{
console.log("clickerdeclick");
$.ajax({
type: "POST",
url: "seenot.php",
async: true,
data: { a: <?php echo $n['id']; ?> , b:<?php echo $user['id']; ?>},
success: function(result){
console.log(result);
console.log("twerkt");
},
error: function (response) {
//if error output data in console
console.log(response);
console.log("lol");
}
});
});
});
这是我的按钮,
<a class="btn btn-default" id="#makeseen-<?php echo $n['id']; ?>"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></a></button>
推荐答案
修复ID属性中没有PHP代码的情况.
Fix the ID attribut to not have PHP code in it.
执行类似的操作(如果您需要PHP的ID:
Do something like this instead (if you need the ID from PHP:
<a class="btn btn-default myButton" data-id="<?php echo $n['id']; ?>">
然后您使用此jQuery:
Then you use this jQuery:
$(".myButton").on("click", function() {
var id = $(this).data("id");
$.ajax({
type: "POST",
url: "seenot.php",
async: true,
data: {"a": id },
...
etc
...
});
});
这篇关于jQuery .click未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文