I'm trying to view my json file to make sur eit's under the right path and to make it into a table. This is my current code
i.API.info('===> assets(resources) dir: ' + Ti.Filesystem.resourcesDirectory); var fileHandle = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'extras/CARINFO.json'); if (fileHandle.exists()) { alert('File handle success! ' + fileHandle); } else { alert('File handle error!'); } */
/*function doClick(e) { alert($.label.text); }
$.index.open();
var url = "https://s3.amazonaws.com/pedruqui/tests/hotels.json"; var json;
var xhr = Ti.Network.createHTTPClient({ onload: function() { // parse the retrieved data, turning it into a JavaScript object json = JSON.parse(this.responseText); // ... }
var data = [];
var url = "http://amigosdelnorte.com.ar/read_todo_list2.php"; var client = Ti.Network.createHTTPClient({ // function called when the response data is available onload : function(e) { Ti.API.info("Received text: " + this.responseText);
var jsonObject = JSON.parse(this.responseText);
//alert(jsonObject.resultset.length);
for (var i = 0; i < jsonObject.resultset.length; i++) {
//alert(json[i].title);
var row = Ti.UI.createTableViewRow({
height : 100
});
// Create a Label.
var title = Ti.UI.createLabel({
text : "id:" + jsonObject.resultset[i].id + "\n" + "local:" + jsonObject.resultset[i].Local + "\n" + "River:" + jsonObject.resultset[i].Visitante,
color : '#000',
font : {
fontSize : 20
},
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
top : 10,
left:10
});
// Add to the parent view.
row.add(title);
data.push(row);
$.table.setData(data);
};
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
}); // Prepare the connection. client.open("GET", url); // Send the request. client.send();
$.index.open(); */ function showItems(e) { Ti.API.info(e.rowData.itemName); } var rowData=[]; for(var i=1;i<=10;i++){ var payload={ rowId:i, itemName:'Test' + i }; var row=Alloy.createController('row',payload).getView(); rowData.push(row); } $.itemsList.data=rowData; $.win.open();