【发布时间】: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”
【问题讨论】: