Hi All i just want to know is it possible to load a Json file from your C:drive if you saved it there as a .txt for testing or can you maybe see the error in my code
var url = "http://WF7_API/api/transaction/inbox/johnny"; var json , Inbox , Task , i , row , TaskName; var table = Ti.UI.createTableView({ top:'12%'}); var tableData = []; var xhr = Ti.Network.createHTTPClient({}); xhr.open("GET", url); xhr.onload = function() { json = JSON.parse(this.responseText); for ( i = 0; i < json.Inbox.length ; i++){ Task = json.Inbox[i]; row = Ti.UI.createTableViewRow( { top:'12%', height:60, }); lblTaskName = Ti.UI.createLabel( { text:Task.Transaction, font:{fontSize:'24dp'}, height:'auto', left:'10dp', top:'50dp', color:'#000', touchEnabled:true, }); row.add(lblTaskName); tableData.push(row); }; table.setData(tableData); } xhr.onerror = function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); } timeout = 5000 xhr.send(); winMail.add(table);Please help
2 Answers
Stiaan, you running this from a Win machine? If so, I don't think the emulator or device will see the local hostname. Instead, try by IP address:
http://192.xxx.xxx.xxx/api/transaction/inbox/johnny // replace ^^^^^^^^^^ with actual local IPI don't have experience working on a Win PC, so let me know if this works.
HTH. Bob
As long as your txt file is located within your Resources directory, you should have no problem reading it for testing.
Your Answer
Think you can help? Login to answer this question!