jQuery等同于Prototype Ajax.Request

web*_*evy 4 ajax jquery prototypejs

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

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

Dar*_*rov 7

你可以使用这个$.ajax()功能

function showSnapshotComments(snapshot) {
    $.ajax({
        url: '/photos/show_snapshot_comments/' + snapshot.id,
        dataType: 'script'
    }); 
}
Run Code Online (Sandbox Code Playgroud)

或者$.getScript()你喜欢哪个函数是等价的:

function showSnapshotComments(snapshot) {
    $.getScript('/photos/show_snapshot_comments/' + snapshot.id); 
}
Run Code Online (Sandbox Code Playgroud)


Wil*_*Niu 5

$.ajax({
  url: '/photos/show_snapshot_comments/'+ snapshot.id,
  async: true,
  dataType: 'script'
});
Run Code Online (Sandbox Code Playgroud)