2014-02-09 18 views
2

我有一個在骨幹內置的phonegap應用程序,並且ajax調用需要非常長的時間。加載46kb json文件的加載時間約爲2分鐘或更長。PhoneGap和主幹Ajax調用需要很長時間

我正在使用ping我的本地node.js服務器的ios模擬器。 node.js服務器對天氣服務執行https.get()請求並將其返回。當我訪問bowser中的網址時,該調用非常快速。

問題與移動內存管理或下劃線模板有關嗎?幫我!謝謝!

//意見/ weather.js

template: _.template($('#hero-1').html()), 

render: function() { 
    var view = this; 
    $(this.el).html(this.template(view.model.toJSON())); 
}, 

getWeatherData: function(lat, long){ 
     view.weatherModel = new this.model(); 
     view.weatherModel.fetch({ 
     data: { 
     longitude: lat, 
     latitude: long 
     }, 
     success: function(data) { 
      view.dataReturned(data.attributes); 
      view.render(); 
     } 
    }); 
}, 

//型號/ weather.js

return Backbone.Model.extend({ 

    url: 'http://127.0.0.1:3000/weather',  

    parse: function(response){ 
     console.log("Parsing Response", response); 
     response.weather.currently.avgTemp = Math.round(response.weather.currently.temperature); 
     return response; 
    } 

}); 

// HTML /模板

<script type="text/template" id="hero-1"> 
    <div id="weather-temp" class="weather-temp"> 
     <%= weather.currently.avgTemp %> 
    </div> 
</script> 

謝謝!

請注意: 如果我做一個標準的調用是這樣的:

$.ajax({ 
      type: "GET", 
      crossDomain:true, 
      async: false, 
      contentType:"application/json; charset=utf-8", 
      url:"http://127.0.0.1:3000/weather?longitude=-122.406417&latitude=37.785834", 
      success:function(data) { 
       console.log('success'); 
       console.log(data); 
      } 
     }); 

它只是超時很快,如果我在模擬器中的Safari瀏覽器的控制檯做,而是將工作。

回答

0

我沒有意識到XCODE會重置ios Simulators的位置。

打開模擬器:

窗口>調試>位置>自定義位置

設置一個新的位置。