Quantcast
Viewing all articles
Browse latest Browse all 8068

Display data from remote DB

Hi, i'm begineer on titanium's developpement. I have a tableview contains list of persons' name retrieved from remote database. when i click on each row of my tableview, i want to display only one information from remote database associeted for this row (the activity of each person of my list). i used a php web services to do this. i used a loop "For" to display data, but the problem that when i click on a row all data are dispalyed on this alerDialog (all activity of persons are displayed). i tried to do this whitout loop, i can display now only the first data from database (on click of each row, only the activity of the first person is displayed for all rows of my tableview). i do not know what exacly should i put as condition or witch loop must be used for this. here is my code : list.js : function doSomething(e) { var sendit = Ti.Network.createHTTPClient({ onerror: function(e){ Ti.API.debug(e.error); alert('There was an error during the connection'); }, timeout:5000, }); sendit.open('GET', 'http://10.0.2.2/list.php'); sendit.send(); //Function to be called upon a successful response sendit.onload = function(){ var json = JSON.parse(this.responseText); var json = json.activity; //if the database is empty show an alert if(json.length == 0){ alert('The database row is empty'); } var dataArray = []; for( var i=0; i<json.length; i++){ var alertDialog = Titanium.UI.createAlertDialog({ title: 'Info Participant', message: json[i].activity, buttonNames: ['Accept','Reject'], cancel: 1 }); alertDialog.show(); dataArray.push(alertDialog); }; }; } and this is my list.xml : <Alloy> <TabGroup id="mainTabGroup"> <Tab id="tab3" onClick="getTodoList"> <Window id="readWin"> <TableView id="tableView" onClick="doSomething"/> </Window> </Tab> </TabGroup> </Alloy>


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>