【问题标题】:Grails GET method for JSON用于 JSON 的 Grails GET 方法
【发布时间】:2012-10-03 12:44:19
【问题描述】:

我正在尝试使用 http GET 方法来检索我创建的 JSON 对象,然后在 Titanium 中我创建了一个检索方法,但它只是检索“未定义”

def listJSON() {
   def converter = User.list() as JSON
   System.out.println(converter)
   render(converter)
   //response(converter)
}

grails 的输出是正确的并且页面呈现(从系统输出):

[{"class":"testingmobile.User","id":1,"age":22,"email":"test@hotmail.com","name":"Ryan","occupation":"Whatever "}]

Titanium 中移动应用的代码如下:

var url = "http://localhost:8080/TestingMobile/user/listJSON";
var client = Ti.Network.createHTTPClient ({
onload : function(e) {
    Ti.API.info("Recieved text: "+ this.responceText);
    var jsonObj = JSON.parse(this.responseText);
    getShow(jsonObj);
    alert('success');
},
onerror : function(e) {
    Ti.API.debug(e.error);
    alert('error');
},
timeout : 5000 
});
client.open("GET", url);
client.send(); 

控制台输出“Received text: undefined”

【问题讨论】:

    标签: json grails get titanium


    【解决方案1】:

    responceText

    应该是

    responseText

    带有 s,而不是 c

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多