gpt4 book ai didi

javascript - FlickrAPI : Uncaught ReferenceError: jsonFlickrApi is not defined 的 jsonp 问题

转载 作者:行者123 更新时间:2023-11-29 22:02:20 27 4
gpt4 key购买 nike

我不确定为什么会不断收到以下错误。

未捕获的 ReferenceError:未定义 jsonFlickrApi

我正在尝试将包含 URL 参数的对象传递给 ajax 调用。

这是一个 fiddle :http://jsfiddle.net/3vRM3/

这是我的 JavaScript:

var TheModel = Backbone.Model.extend({
default: {
photos: '',
stat: ''
}
});

var TheCollection = Backbone.Collection.extend({
model: TheModel,

url: 'http://api.flickr.com/services/rest/'

});

// The main view
var List = Backbone.View.extend({
el: '.js-container',

initialize: function () {
this.collection = new TheCollection();

return this;
},

render: function () {
var self = this;

var urlParameters = {
page : '1',
api_key: 'xxxxxxxxxxxxxxxxxxxxx',
tags: "candy",
method: 'flickr.photos.search',
per_page: '3',
format: 'json',
jsoncallback: '?'
};

this.collection.fetch({
dataType: 'jsonp',
data: urlParameters,
success: function (data) {
console.log('success');
console.log(self.collection);

}
});

return this;
}

});


var myList= new List();
myList.render();

这是我的 HTML:

<script type="text/template" id="DropdownList">
<% console.log('this is the template') %>
<h3>Stat = <%- collection[0].stat %></h3>
</script>

<div class="js-container">
</div>

最佳答案

查看响应:

jsonFlickrApi({"photos":{"page":1,"pages":144580,"perpage":3,"total":"433738","photo":[{"id":"13721741393","owner":"31558746@N00","secret":"1965a3793c","server":"5117","farm":6,"title":"Candy corn","ispublic":1,"isfriend":0,"isfamily":0},{"id":"13721755993","owner":"31558746@N00","secret":"c4eb729500","server":"2938","farm":3,"title":"Candy corn","ispublic":1,"isfriend":0,"isfamily":0},{"id":"13722064924","owner":"31558746@N00","secret":"b8662de0bb","server":"3723","farm":4,"title":"7-Layer Candy Dip","ispublic":1,"isfriend":0,"isfamily":0}]},"stat":"ok"})

他们正在使用 JSONP 并将回调设置为 jsonFlickrApi

关于javascript - FlickrAPI : Uncaught ReferenceError: jsonFlickrApi is not defined 的 jsonp 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22945503/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com