I am trying to use the http GET method to retrieve JSON object I have created, then in Titanium I have created a method to retrieve, however it is only retrieving “undefined”
def listJSON() {
def converter = User.list() as JSON
System.out.println(converter)
render(converter)
//response(converter)
}
The output from grails is correct and the page rendered (from system out) :
[{"class":"testingmobile.User","id":1,"age":22,"email":"test@hotmail.com","name":"Ryan","occupation":"Whatever "}]
The code from the mobile app in Titanium is as follows:
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();
The console outputs “Received text: undefined”
responceTextshould be
responseTextwith an s, not a c.