这是我的情况
var player = new Backbone.Model.extend({});
var QuerySolarModel = Backbone.Collection.extend({
model: player,
url : function (){
return myurl";
},
});
this.list = new QuerySolarModel();
this.list.filter= filter;
this.list.fetch({
dataType: "jsonp",
success: function(){
console.log('success');
},
error: function(data, response) {
console.log("errore ");
}
}).complete(function () {alert("done");});
console.log('la lista dovrebbe essere '+this.list);
我通过外部网址获取了一个集合,网址的答案是
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"indent":"true",
"q":"FULLNAME:MINO",
"wt":"json"}},
"response":{"numFound":18,"start":0,"docs":[
{
"id":"2",
"PHYSICAL_CUSTOMER_DATA_ID":"5",
"CONTRACT_IDENTITY":"0000000002",
"STATUS_ID":"3",
"STATUS_DESC":"Suspended",
"FULLNAME":"MINO MAX",
"GAME_ACCOUNT_ID":"1000000038",
"ADDRESS":"VIA ROMA_1 VIA ROMA_2 VIA ROMA_3",
"EMAIL":["l.ghionna@mail.it",
"3475061120"],
"_version_":1432013050215399424},
{
"id":"3",
"PHYSICAL_CUSTOMER_DATA_ID":"6",
"CONTRACT_IDENTITY":"0000000003",
"FULLNAME":"MINO MAX",
"GAME_ACCOUNT_ID":"1000000045",
"ADDRESS":"VIA ROMA_1 VIA ROMA_2 VIA ROMA_3",
"EMAIL":["3475061120",
"l.ghionna@mail.it"],
"_version_":1432013050244759552}]
}}
我想为每个"玩家制作一个模型集合" 但浏览器回答我:
资源解释为脚本,但使用MIME类型text / plain传输:" myurl"。的jquery.js:8169
Uncaught SyntaxError:意外的令牌:select:1
我错误的地方?
编辑: 我理解为什么它不工作, 如果你使用jsnop它必须用回调包裹({你的json})mmm现在能做什么?
答案 0 :(得分:0)
尝试从选项中删除dataType: "jsonp"
。
此外,您的代码无效 - > return myurl";