我的AJAX功能並不像我期望的那樣工作。jQuery AJAX成功上下文
AJAX成功回調中的「this」似乎並不是指showSnapshotComment函數範圍內的「this」。
我試過使用上下文它仍然不工作。我的用法可能不正確。我可能會推翻它。
function showSnapshotComments(snapshot) {
var self = $j(this);
alert($j(this).attr('class'));
$j.ajax({
cache: false,
context: this,
url: 'show_snapshot_comments/' + snapshot.id,
async: true,
dataType: 'script',
success: function() {
$j('#snapshots a.photo').each(function(i) {
$j(this).qtip({
content: $j(this).nextAll('.info').eq(i),
position: {
target: 'mouse',
adjust: { mouse: true },
viewport: $j(window)
},
hide: {
event: 'click mouseleave',
delay: 300
},
show: {
solo: true,
event: 'click mouseenter'
},
style: {
tip: true,
classes: "ui-tooltip-light"
}
});
});
}
});
}