Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying $.ajax JSONP Callback Name in Zepto

In jQuery,

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

sends a request to the following URL:

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

But in Zepto, the same function call sends a request to:

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

The Reddit API requires the JSONP callback to be named 'jsonp'. Looking through the Zepto source, I get the feeling the 'jsonp' option is not supported.

How can I emulate this jQuery behaviour in Zepto?

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. I'm curious if there's a more idiomatic way of doing this.

like image 270
Maros Avatar asked Oct 21 '22 22:10

Maros


1 Answers

In Zepto:

$.ajax({ 
    url: 'http://reddit.com/r/aww.json?jsonp=?'
});
like image 90
mislav Avatar answered Nov 04 '22 00:11

mislav