You can use the $.ajax() function
function showSnapshotComments(snapshot) { $.ajax({ url: '/photos/show_snapshot_comments/' + snapshot.id, dataType: 'script' }); }
or $.getScript() if you prefer, which is equivalent to:
function showSnapshotComments(snapshot) { $.getScript('/photos/show_snapshot_comments/' + snapshot.id); }
source share