Hi, I'm having a hard time while parsing a remote JSON file which I obtain using HTTPClient. The "onload" event fires up, but the responseText property is empty, even when the JSON file is not. The JSON file is 35Kb and I did test what could happend if I shorten it a bit. I've seen that, if the JSON file is a small one I don't have this problem. Is there a limit about how much data can the responseText property can hold?
APP Type: Mobile Ti SDK: Build: 2.1.0.201206251749 | jenkins-titanium-rcp-master-218 (origin/master) Platfrom: Android Version: 2.2 Device: Emulator Host: Debian x64
var httpClient = Ti.Network.createHTTPClient({ timeout: 5000, onload: function( e ) { alert( this.getResponseText() );//this.responseText is empty too }, }); httpClient.open( 'GET', 'url.bla.bla' );//url is valid, just a private one. httpClient.send();JSON file contents: (Working)
{"canales":[{"grupo":"uchile.4.2005.0.ADI001.1","autor":"13047454","fecha":"2012-06-15 12:24:59","serv_nombre":"Material Docente","serv_nombre_interno":"material_docente","serv_url":"https://adi2.ing.uchile.cl/~andregon/ucursos/ucursos/uchile/2005/0/ADI001/1/material_docente/","titulo":"GUIA completo.txt","mensaje":"GUIA completo.txt","url":"https://adi2.ing.uchile.cl/~andregon/ucursos/ucursos/uchile/2005/0/ADI001/1/material_docente/objeto/375331"}]}If the above entry (everything between []) is repeated 90 times (which is the times on the actual file) the responseText is empty.
4 Answers
Try
this.responseTextinstead of
this.getResponseText()I have run into a number of situations on android where the getter function doesn't work (on various different objects and properties throughout Titanium), but direct access to the property does work.
Can you try and increase the timeout? Or even remove it, to see if that has any effect?
Just wondering if you can get it to work outside of the Titanium Environment? Have you tried just doing the same request in a browser to see if it works. I always seem to find my mistakes that way.
In the end, was a matter of encodings between the server, the file and the httpClient. I didn't notice the error line in the console, so I'm the one to blame here. :P
Anyway, moral of the story: double check ALL the encodings!
Your Answer
This question has been locked and cannot accept new answers.