jQuery等同于Prototype Ajax.Request

时间:2011-04-04 22:03:35

标签: jquery ajax prototypejs

与以下Prototype AJAX请求相当的jQuery是什么?

function showSnapshotComments(snapshot) {
   new Ajax.Request('/photos/show_snapshot_comments/'+ snapshot.id,
                    {asynchronous:true, evalScripts:true});
}

2 个答案:

答案 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'
});