如何通过按钮的onclick函数处理jQuery的事件如何通过按钮处理jQuery的事件的onclick功能
HTML代码
<div id="comments" class="cmt" >
<img width="30px" height="30px" src="/cropphoto/<?php echo getuserPhoto($d['uid']); ?>">
<input class="commentbox" id="comment" name="comments" placeholder="Comment Here" maxlength="50" >
<input type="hidden" id="qid" name="qid " value="<?php echo $d['qid'];?>">
<button type="button" id="comq" name="compost" onclick="my(event,<?php echo $d['qid'];?>);" class="butn2" >post comment</button>
</div>
AJAX JQUERY
$(document).ready(function() {
$("#comq").click(function my(e, id) {
var comment = $("#comment").val();
var qid = $("#qid").val();
alert(qid);
$.ajax({
cache: false,
type: "post",
url: "jquery.php",
data: {
comments: comment,
qid: qid
},
success: function(data) {
$("#comment").val("");
$("").html(data);
}
});
});
});
评论没有插入通过点击功能按钮进入数据库,但没有按键w工作会有细微什么是错在我的代码,请让我知道我现在是在阿贾克斯
哪里是我的函数 – Gardezi
@Gardezi看到AJAX请让我知道我做了什么错误,我在阿贾克斯新,jQuery的 –
是的,我看到了它。你正在调用一个函数''onclick =“my(event,<?php echo $ d ['qid'];?>);”onclick。但我没有看到它在任何地方定义 – Gardezi