Titanium + AJAX and array -


the question in title. make request titanium.network.httpclient

assuming result of call (ty var_dump) : array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" }

edit : here complete function.

var paramsrecepteur = "demande=recepteur"; var client = ti.network.createhttpclient({     // si la rĂ©ponse est ok     onload : function(e) {         ti.api.info("**************************************");         var results = json.parse(this.responsetext);         ti.api.info(results[0]);         ti.api.info("**************************************");     },     // si erreur . ou timeout !     onerror : function(e) {         alert("erreur recepteur");     },     timeout : 5000 // implique un probleme reseau }); ti.api.info("¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤"); ti.api.info(url); // url defined upper & correct. ti.api.info("¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤"); client.setrequestheader("content-type", "application/x-www-form-urlencoded"); client.setrequestheader("content-length", paramsrecepteur.length); client.setrequestheader("connection", "close"); client.open("post", url, true); client.send(paramsrecepteur); 

edit 2 : carefull send json object, , not php array ...

thinqs.

you have wrong variable names. proper way of these shown below:

var client = ti.network.createhttpclient({     onload : function(e) {         // print         ti.api.info(this.responsedata);          ti.api.info(this.responsexml);          ti.api.info(this.responsetext);          // parse results         var results = json.parse(this.responsetext);         ti.api.info(results[0]); // print first index of array     } }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -