我有一个内置在主干上的phonegap应用程序,ajax调用花费了相当长的时间。加载约2分钟或更长的时间来加载一个46 is的json文件。
我正在使用ios模拟器,它正在敲击我的本地node.js服务器。node.js服务器对天气服务执行https.get()请求并返回它。当我去打保龄球的时候,这个电话很快就会响了。
这个问题与移动内存管理或下划线模板有关吗?帮帮我!谢谢!
// views.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();
}
});
},// models/风化.
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控制台中这样做,它就会工作。
发布于 2014-02-24 21:57:46
我没有意识到XCODE会重置ios模拟器的位置。
打开模拟器:
window>Debug>Location>Custom定位
设定一个新的地点。
https://stackoverflow.com/questions/21661025
复制相似问题