我有一个表格
<form method="POST" action="">
<div class="commentdiv">
<input type="hidden" name="id" id="id" class="id" value="<?php echo $pixid;?>">
<input type="hidden" name="username" id="username" value="<?php echo $activeusername;?>">
<input type="hidden" name="uid" id="uid" value="<?php echo $id3;?>">
<textarea style="" name="comment" id="comment" class="comment" placeholder=" comment here"></textarea>
<button type="button" style="background-color: Transparent; background-repeat:no-repeat; border: none; cursor:pointer; overflow: hidden; color: #3897f0; font-weight:600;"class="submit">
comment
</button>
</div>
</form>
这是我的JavaScript
$(document).on('click','.submit',function(e){
e.preventDefault();
$post = $(this);
var username2 = $(this).parent().find("#username").val();
var comment2 = $(this).parent().find("#comment").val();
$commentsec = $(this).closest("form").next(".comments");
//Get values of input fields from DOM structure
var dataString = {
id: $(this).parent().find("#id").val(),
username: $(this).parent().find("#username").val(),
uid: $(this).parent().find("#uid").val(),
comment: $(this).parent().find("#comment").val()
};
//Get values of input fields from DOM structure
var dataString = {
id: $(this).parent().find("#id").val(),
username: $(this).parent().find("#username").val(),
uid: $(this).parent().find("#uid").val(),
comment: $(this).parent().find("#comment").val()
};
$.ajax({
url:'comments.php',
data:dataString,
success:function(){
$commentsec.append('<p class="written"><a href="users.php?id= <?php echo $id3; ?>"><b style=color:black !important>'+username2+'</b> </a>'+comment2+"</p>"+'<div class="dropdown"><img src="ellipsis.png" class="dots"><div class="dropdown-content"><br><p class="delete" data-delete=<?php echo $commentid; ?>">delete</p></div></div>');
$(" #comment").val("");
}
});
});
我希望每当用户单击此按钮时,都会弹出一个警报,并且该用户应该在此表单上添加注释,该表单已由用户编写,整个代码在谷歌chrome浏览器中运行正常,但在Firefox chrome或Microsoft Edge中无法运行我不知道该怎么办