Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery equivalent to Prototype Ajax.Request

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});
}
like image 632
webbydevy Avatar asked Dec 16 '22 15:12

webbydevy


2 Answers

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); 
}
like image 143
Darin Dimitrov Avatar answered Dec 24 '22 15:12

Darin Dimitrov


$.ajax({
  url: '/photos/show_snapshot_comments/'+ snapshot.id,
  async: true,
  dataType: 'script'
});
like image 37
William Niu Avatar answered Dec 24 '22 15:12

William Niu