데이터를 가져 오는 데 다음 코드를 사용하고 있는데 아무 반응이 없습니다. 여기 내 PHP 코드가 있습니다.Titanium 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