我想隱藏圖像的AJAX完成後:元素不是隱藏
$('img[src$="control-power.png"]').on('click',function(){
var id = $(this).attr("id");
id = id.substring(8);
var user_id = $('#del_'+id).val();
var donne = "pk="+user_id;
$.ajax({
data: donne,
type: "POST",
url: "<?php echo HTTP_AJAX ?>admin/validerUtilisateurAjax.php", // updating a row in the database
async: false,
success: function() { $(this).hide(); }
});
});
的圖像是一個表內:
<table id="table" class="data display ">
<thead style="background-color:#CCC">
<tr>
<th>Noms</th>
<th>N° téléphone</th>
<th>Région</th>
<th>Ville</th>
<th width="5%"></th>
<th width="5%"><input type="checkbox" id="check_all" style="position: relative; top: 0px; left: 1px;"></th>
<th width="5%"></th>
</tr>
</thead>
<tbody style="background-color:#FFF">
<tr class="odd gradeX">
<td>Andriniaina Jean Aimé</td>
<td>261324494922</td>
<td>Boeny</td>
<td>Mahajanga I</td>
<td align="center" style="vertical-align:middle"><a href="admin.php?action=AdminModifierUtilisateur&id=269"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" style="height:10px;width:10px;"></a></td>
<td align="center" style="vertical-align:middle"><input type="checkbox" id="del_0" value="269"></td>
<td align="center" style="vertical-align:middle"><a><img src="http://localhost/bazarmada/pages/img/icons/control-power.png" id="valider_0" style="height:10px;width:10px;cursor:pointer"></a></td>
</tr>
<tr class="odd gradeX">
<td>Andriniaina Nomenjanahary Todisoa</td>
<td>261328981998</td>
<td>Analamanga</td>
<td>Ambohidratrimo</td>
<td align="center" style="vertical-align:middle"><a href="admin.php?action=AdminModifierUtilisateur&id=208"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" style="height:10px;width:10px;"></a></td>
<td align="center" style="vertical-align:middle"><input type="checkbox" id="del_1" value="208"></td>
<td align="center" style="vertical-align:middle"><a><img src="http://localhost/bazarmada/pages/img/icons/control-power.png" id="valider_1" style="height:10px;width:10px;cursor:pointer"></a></td>
</tr>
<tr class="odd gradeX">
<td>Andriniaina Nomenjanahary Todisoa</td>
<td>261325306341</td>
<td>Analamanga</td>
<td>Ambohidratrimo</td>
<td align="center" style="vertical-align:middle"><a href="admin.php?action=AdminModifierUtilisateur&id=635"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" style="height:10px;width:10px;"></a></td>
<td align="center" style="vertical-align:middle"><input type="checkbox" id="del_2" value="635"></td>
<td align="center" style="vertical-align:middle"><a><img src="http://localhost/bazarmada/pages/img/icons/control-power.png" id="valider_2" style="height:10px;width:10px;cursor:pointer"></a></td>
</tr>
</tbody>
</table>
但問題是,在運行數據庫更新,但圖像仍然顯示!那爲什麼不隱藏呢?
'this'是不同的東西,一旦你的AJAX調用裏面 - 它之前分配給VAR ajax並在你的成功中使用 – Pete 2014-10-08 07:46:07