试图让这段代码工作,但我的萤火得到的错误是$this is not defined
,我不明白为什么
为了解释这个代码的背景我的列表跨越相同的类,所以当我点击特定的跨度时,我需要发送一个Ajax请求并更新该特定的跨度。
希望这是有道理的。
$(document).ready(function() {
function postAndFade($node, post_key) {
var id = $node.parents('.id').find('.id-value').text();
var post_val = $node.text();
$node.fadeOut('slow');
$.ajax({
type: "POST",
url: "process.php",
data: "id="+id+"&"+post_key+"="+post_val,
success: function(data) {
$node.html(data);
$node.fadeIn('slow');
}
});
return false;
}
$('.featured-value').click(function() { return postAndFade($this, 'featured'); });
$('.visible-value').click(function() { return postAndFade($this, 'visible'); });
});
我不说话了jQuery,但它真的有所谓的“$这个”东西吗?也许你的意思是'这个'或'$(this)'? –
你确定这是导致错误的代码块吗? – kand