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});
}
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'
});
精彩评论