与以下Prototype AJAX请求相当的jQuery是什么?
function showSnapshotComments(snapshot) {
new Ajax.Request('/photos/show_snapshot_comments/'+ snapshot.id,
{asynchronous:true, evalScripts:true});
}
答案 0 :(得分:7)
您可以使用$.ajax()
功能
function showSnapshotComments(snapshot) {
$.ajax({
url: '/photos/show_snapshot_comments/' + snapshot.id,
dataType: 'script'
});
}
或$.getScript()
函数,如果您愿意,它是等效的:
function showSnapshotComments(snapshot) {
$.getScript('/photos/show_snapshot_comments/' + snapshot.id);
}
答案 1 :(得分:5)
$.ajax({
url: '/photos/show_snapshot_comments/'+ snapshot.id,
async: true,
dataType: 'script'
});