哪个是最好的 sencha 或 Phonegap 与 restful Web 服务通信,解析 json 数据,然后将其显



我需要构建一个移动应用程序,该应用程序应该与 restful Web 服务通信,解析来自它的 json 数据,然后将其呈现给用户。我需要创建一个混合应用程序,那么在这种情况下哪个更好,是 Phonegap 还是煎茶?

Sencha 提供了 API 来执行 Ajax 调用。你可以使用phonegap + jquery做同样的事情。所以两者都很容易。我确实更喜欢电话差距,但这只是个人意见。

我在Phonegap应用程序中使用JQuery。Phonegap旨在抽象出您与移动设备API的交互,而不是服务器通信和JSON解析。

使用

JQuery,您只需使用标准的 AJAX 调用和 JSON.parse/JSON.stringify 进行 JSON 解析。

this.refreshPreferences = function(inBackground){
    console.log("Refreshing preferences");
    var self = this;
    $.ajax({
      url: getBaseUrl()+"/prefs/index.jsonp",
      dataType: "jsonp",
      crossDomain: true,
      timeout: 2500,
      data: {
        auth_token: storage.getItem('auth_token')
      }
    })
    .done( function ( response ) {
      storage.setItem(LS_PREFERENCES_KEY,JSON.stringify(response));         
    })
    .fail( function (){
      console.log("Unable to communicate with server");
    })
};

最新更新