0

这是我的情况

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);

我必须通过外部 url 获取集合,url 的答案是

    {
  "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 类型文本/纯文本传输:“myurl”。jquery.js:8169

未捕获的语法错误:意外的令牌:选择:1

我在哪里弄错了??

编辑:我明白为什么它不起作用,你使用 jsnop 它必须由回调({your json})mmm 包装,现在我能做什么?

4

1 回答 1

0

尝试dataType: "jsonp"从选项中删除。

您的代码也无效->return myurl";

于 2013-04-11T19:07:55.050 回答