2017-01-14 74 views
-1

我試圖弄清楚這一點(相當多的帖子關於這個問題已經),但不幸的是我無法弄清楚。骨幹抓取:{「readyState」:0,「responseText」:「」,「status」:0,「statusText」:「error」}只在手機上

我有一個簡單的服務,我試圖用來獲取和顯示一些數據。一切工作桌面上很好,但在移動我只是一直在每次取下面的錯誤得到: 警報(「錯誤:」 + JSON.stringify(XMLHttpRequest的)):

​​

這裏是我的代碼:

$(window).load(function(){ 

    var Tweet = Backbone.Model.extend({ 
    defaults: function() { 
     return { 
     DateTime: 0, 
     Tweet: "" 
     }; 
    } 
    }); 

    var TweetsCollection = Backbone.Collection.extend({ 
    model: Tweet, 
    url: "http://11.112.101.221:8880/bananas" //url was changed 
    }); 

    this.tweetsCollection = new TweetsCollection(); 

    this.tweetsCollection.fetch({ 
     reset: true, 
     success: function(request, data){ 
     //alert("success:" + data); 
     console.log("onSuccess") 
     }, 
     error: function(request, error){ 
     alert("error:" + JSON.stringify(error)); 
     } 
    }); 


    var TweetsView = Backbone.View.extend({ 

    tagName: "li", 
    template: _.template($('#item-template').html()), 

    initialize: function() { 
     this.listenTo(this.model, 'change', this.render); 
     this.listenTo(this.model, 'destroy', this.remove); 
    }, 

    // Re-render the titles of the todo item. 
    render: function(event) { 
     event && event.preventDefault(); 
     this.$el.html(this.template(this.model.toJSON())); 
     return this; 
    }, 

    // Remove the item, destroy the model. 
    clear: function() { 
     this.model.destroy(); 
    } 
    }); 

    var AppView = Backbone.View.extend({ 
    el: $("#warnupapp"), 

    initialize: function() { 
     this.listenTo(tweetsCollection, 'add', this.addOne); 
     this.listenTo(tweetsCollection, 'all', this.render); 
     this.main = $('#main'); 
     console.log("fetching..") 
     tweetsCollection.fetch(); 
    }, 

    render: function() { 
     this.main.show(); 
    }, 

    addOne: function(tweet) { 
     var view = new TweetsView({model: tweet}); 
     this.$("#tweets-list").append(view.render().el); 
    } 

    }); 

    console.log("starting..") 
    var App = new AppView; 
}); 

回答

0

2天后我發現問題出在我的服務器端,在那裏我不允許我的休息方法交叉來源。設置完成後,一切正常。

相關問題