简体   繁体   English

在Zepto中指定$ .ajax JSONP回调名称

[英]Specifying $.ajax JSONP Callback Name in Zepto

In jQuery, 在jQuery中,

$.ajax({ 
    url: 'http://reddit.com/r/aww.json', 
    dataType: 'jsonp',
    jsonp: 'jsonp'
});

sends a request to the following URL: 向以下URL发送请求:

http://www.reddit.com/r/aww.json?jsonp=jsonp1354967449950 . http://www.reddit.com/r/aww.json?jsonp=jsonp1354967449950

But in Zepto, the same function call sends a request to: 但在Zepto中,相同的函数调用发送请求:

http://www.reddit.com/r/aww.json?callback=jsonp4

The Reddit API requires the JSONP callback to be named 'jsonp'. Reddit API要求将JSONP回调命名为'jsonp'。 Looking through the Zepto source, I get the feeling the 'jsonp' option is not supported. 通过Zepto源代码,我感觉不支持'jsonp'选项。

How can I emulate this jQuery behaviour in Zepto? 如何在Zepto中模拟这个jQuery行为?

Note: I'm trying to get this behaviour in Backbone.js by overriding a collection's sync function and calling collection.fetch(), similar to this code: https://gist.github.com/1245613 . 注意:我试图通过覆盖集合的sync函数并调用collection.fetch()来在Backbone.js中获取此行为,类似于以下代码: https//gist.github.com/1245613 I'm curious if there's a more idiomatic way of doing this. 我很好奇是否有更惯用的做法。

In Zepto : 在Zepto

$.ajax({ 
    url: 'http://reddit.com/r/aww.json?jsonp=?'
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM