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();
コンソールは「受信したテキスト: 未定義」を出力します