jQuery 相当于原型(prototype) Ajax.Request

标签 jquery ajax prototypejs

相当于以下原型(prototype) AJAX 请求的 jQuery 是什么?

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

最佳答案

您可以使用$.ajax()功能

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

$.getScript()如果您愿意,可以使用等效的函数:

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

关于jQuery 相当于原型(prototype) Ajax.Request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5544871/

相关文章:

jquery - 如何多次使用css transition?

javascript - 双向无限滚动 - 向上和向下

ajax - 错误: Content-Type is not allowed by Access-Control-Allow-Headers

jquery - $.extend 不是函数

javascript - 无法弄清楚我的 Carousel 出了什么问题

javascript - 原型(prototype)获取名为 Slideshow 的 div 中的所有 img 标签

javascript - Bootstrap 弹出窗口焦点不起作用

java - 让 Ajax 应用程序知道服务器上的错误的最佳方法是什么?

javascript - 用 jQuery 实现 "this is taking too long"消息

javascript - 语法 :Error JSON. 解析,尝试为 protovis 加载数据时