javascript - jquery 不在 IE、EDGE 和 FIREFOX 中工作,但在 CHROME 中工作
问题描述
我有一个表格
<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("");
}
});
});
我希望每当用户单击此按钮时,都会弹出一个警报,并且该评论应附加到用户现在编写的此表单中,这整个代码在 google chrome 中运行良好,但在 firefox chrome 或 microsoft edge 中无法运行,我不知道该怎么办
解决方案
推荐阅读
- c++ - \mingw-w64\ ... \ld.exe: 找不到 -lboost_filesystem
- python - 我需要一些关于 keras 图像分类器项目的帮助
- android - 安卓。ApplicationProvider 去哪儿了?
- c# - C# - 闭包如何在 lambda 中工作以及垃圾收集器如何处理它们?
- c++ - 我如何在标准输出的特定位置写入?
- java - 通过使用 Java 8 将元素添加到链表中来比较数组列表和链表
- php - 如何更改 PDO(SELECT / WHERE)获取查询返回的关联数组中的字段名称?
- r - 如何在 R 中为粒子运动设置动画
- ssis - 如何使用 SSIS 配置管理器?即轻松将开发或测试或生产配置设置为流程?
- ruby-on-rails - 是否有可能以编程方式从 sidekiq 作业中检索批处理 ID 或从批处理中获取活动/待处理作业 ID?