2 回答

TA贡献1836条经验 获得超5个赞
您编写的代码不会在处理后隐藏元素。#loading
如果可能的话,我需要首先看到你的html代码,如果它不可能,所以你需要在你的过程完成后隐藏你的元素,之后你将能够再次显示它。#loading
当加载没有隐藏并且只是显示时,您的代码在第一时间如何正常工作?
如果它将在加载后被删除,那么您也需要加载元素。#loading

TA贡献1775条经验 获得超8个赞
在每行上放置一个类并删除 id。利用获取与类匹配的所有元素的功能,并将事件挂接到与类匹配的每个元素。然后在函数中使用以获取行,并从那里导航到子项。$(this).parent()
这只是一种改进代码的策略,而不是具体的答案,但是如果您遵循此方法,则可能更容易推断出错误所在。
$(document).ready(function() {
$(".js-action").submit(function() {
var row = $(this).parent('.row');
$.ajax({
type: $(this).attr('method'),
url: 'Update.php',
data: $(this).serialize(),
success: function (data) {
row.find('.response-image').show();
},
error: function(jqXHR, textStatus, errorThrown){
console.log("The following error occured: "+textStatus,errorThrown);
}
});
});
<!-- this gets repeated a bunch of times. No need for ids -->
<div class="row">
<form class="response" method="post" autocomplete="off">
<input type="hidden" value="<?php echo $row['Id']?>" name="id">
<input class="input-2" type="text" name="returnid" value="<?php echo $row['returnID']; ?>">
<input type="submit" name="submit-form" class="buttonSubmitHide" />
</form>
</div>
添加回答
举报