私はデータをプルするために次のコードを使用していると何も起こりません。ここに私のPHPコードがあります。チタンAppcelerator - リモートデータを引き出す方法
$getall = "SELECT * FROM pages WHERE account_id=$id ORDER BY course_id";
$showall = @mysqli_query ($dbc, $getall); // Run the query.
$json = array();
if (mysqli_num_rows($showall) > 0)
{
while ($row=$showall->fetch_assoc()) {
$json[]=array(
'logged' => true,
'pagename'=>$row['pagename'],
);
} // end while
header("Content-Type: text/json");
echo json_encode(array('pages' => $json));
}
ここで私のJSコードは、アプリケーションを実行します。
sendit.open('GET', 'http://myurl.com/mypages.php');
sendit.send();
sendit.onload = function(){
var json = JSON.parse(this.responseText);
var json = json.pages;
var dataArray = [];
var pos;
for(pos=0; pos < json.length; pos++){
dataArray.push({title:'' + json[pos].pagename + ''});
// set the array to the tableView
tableview.setData(dataArray);
};
};
var tableview = Ti.UI.createTableView({
});
currentWin.add(tableview);
私がアプリを実行すると、空白のテーブルが表示されます。どんな助けでも大歓迎です。
json配列の長さかサンプルjson文字列をチェックしてください – Triode