首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PhoneGap和主干Ajax调用需要很长时间

PhoneGap和主干Ajax调用需要很长时间
EN

Stack Overflow用户
提问于 2014-02-09 15:32:03
回答 1查看 298关注 0票数 2

我有一个内置在主干上的phonegap应用程序,ajax调用花费了相当长的时间。加载约2分钟或更长的时间来加载一个46 is的json文件。

我正在使用ios模拟器,它正在敲击我的本地node.js服务器。node.js服务器对天气服务执行https.get()请求并返回它。当我去打保龄球的时候,这个电话很快就会响了。

这个问题与移动内存管理或下划线模板有关吗?帮帮我!谢谢!

// views.js

代码语言:javascript
复制
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/风化.

代码语言:javascript
复制
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/模板

代码语言:javascript
复制
<script type="text/template" id="hero-1">
   <div id="weather-temp" class="weather-temp">
      <%= weather.currently.avgTemp %>
   </div>
</script>

谢谢!

请注意:如果我做这样的标准电话:

代码语言:javascript
复制
$.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控制台中这样做,它就会工作。

EN

回答 1

Stack Overflow用户

发布于 2014-02-24 21:57:46

我没有意识到XCODE会重置ios模拟器的位置。

打开模拟器:

window>Debug>Location>Custom定位

设定一个新的地点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21661025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档