开发者

jQuery equivalent to Prototype Ajax.Request

开发者 https://www.devze.com 2023-02-21 20:39 出处:网络
What would be the jQuery equivalent to the following Prototype AJAX Request?开发者_开发百科 function showSnapshotComments(snapshot) {

What would be the jQuery equivalent to the following Prototype AJAX Request?开发者_开发百科

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


You could use the $.ajax() function

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

or the $.getScript() function if you prefer which is equivalent:

function showSnapshotComments(snapshot) {
    $.getScript('/photos/show_snapshot_comments/' + snapshot.id); 
}


$.ajax({
  url: '/photos/show_snapshot_comments/'+ snapshot.id,
  async: true,
  dataType: 'script'
});
0

精彩评论

暂无评论...
验证码 换一张
取 消