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>
添加回答
舉報