這是我的AJAX的jQuery位:..........無法添加變量的成功函數
$(function() {
$(".follow").click(function() {
var element = $(this);
var I = element.attr("id");
var info = 'id=' + I;
$.ajax({
type: "POST",
url: "follow.php",
data: info,
success: function() {
$('.follow' + I).fadeOut(200).hide();
$('.following' + I).fadeIn(200).show();
}
});
return false;
});
});
我的HTML是:
echo "<tr>";
echo '<td>'. $table["username"]. '</td>'.'<td>'.'<a href="#" id="'.$table['id'].'" class="follow">'.'</a>' . '<a href="#" id="'.$table['id'].'" class="following" style="display:none">'.'</a>' . '</td>';
echo "<tr>";
(這是在一個while循環)
成功,我試圖淡出跟隨按鈕(與其ID),並用相同的ID替換它下面的按鈕 - 但是當使用(+ I)它不似乎在工作?
我哪裏錯了?
您是否收到錯誤消息? – lvil
這兩個鏈接是否相同? ** $ table ['id'] ** – Nowshath