0

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

4

2 回答 2

0

Sencha 提供 api 来进行 Ajax 调用。您可以使用phonegap + jquery 来做同样的事情。所以两者都很容易。我确实更喜欢phonegap,但这只是个人意见。

于 2013-09-25T11:00:16.793 回答
0

为此,我在 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");
    })
};
于 2013-09-25T11:01:41.857 回答