2011-10-07 30 views
0

我正在使用AppMobi.device.getRemoteData方法从我托管在公共服务器上的web服务获取数据。这个web服务每次访问它时都返回一个随机数。AppMobi .device.getRemoteData缓存

当我在XDK的模拟器上测试我的应用程序(在Chrome中)时,我每次都得到随机数。

但是,当使用“测试任何地方”功能在我的iPad上测试应用程序时,我第一次得到随机值,然后我为随后的请求获得相同的值。 似乎有些东西正在iPad上测试,而我无法弄清楚。

任何有关这个问题的帮助将不胜感激。

我粘贴了下面的代码。

由于提前, 阿希什

getValue = function() { 

      AppMobi.device.getRemoteData("http://122.181.151.75/DwebMobile/RandomNumService.svc/GetRandomValue", "GET", "", "success_handler", "error_handler"); 
     } 

    function success_handler(data) { 
      var ret = JSON.parse(data); 
      var canvas = document.getElementById('id1'); 
      if (canvas.getContext) { 
       var ctx = canvas.getContext('2d'); 
       ctx.clearRect(0, 0, canvas.width, canvas.height); 
       drawShape(); 
       ctx.fillStyle = '#FF0000'; 
       ctx.font = 'italic 12px sans-serif'; 
       ctx.textBaseline = 'top'; 
       ctx.fillText(ret.d, 22, 70); 
      } 
      AppMobi.Cache.clearAllCookies(); 
     } 
     function error_handler(data) { alert("error: " + data); } 



<body> 
     <button id="btnBeep" ontouchstart="getValue();"> 
      Get Value</button> 
     <canvas id="id1"></canvas> 
    </body> 
+0

fillText有可能失败。您是否尝试提醒数据在设备上检查它? – user983792

回答

1

我们在应用*实验室测试基本的随机数Web服务调用。 AppMobi.device.getRemoteData不会缓存结果,所以错误出现在您的JavaScript代码中。

Ian