JSON 배열을 반환하는 PHP 파일이 있습니다. 배열 이름을 추출해야합니다.이 예제에서는 * Regulatory_Guidance_Library *를 jQuery와 함께 사용하여 $('#navHeaderTitle').text(arrayName);
의 var 함수로 추출해야합니다. 나는 이것이 어떻게 행해졌는지 모른다. 당신의 도움에 대한PHP JSON 배열 이름을 추출하는 방법
Thnx
는 HTML 문서에서 내 기능 :
function loadNav(url, container, appendE) {
$.getJSON(url, function(data){
var arrayName = "";
$.each(data.Regulatory_Guidance_Library, function(){
var newItem = $('#' + container).clone();
// Now fill in the fields with the data
newItem.find("h1").text(this.label);
newItem.find("h2").text(this.title);
newItem.find("p").text(this.description);
// And add the new list item to the page
newItem.children().appendTo('#' + appendE)
});
$('#navHeaderTitle').text(arrayName);
//transition(pageName, "show");
});
};
서비스하는 PHP :
<?php
//MySQL Database Connect
include 'andaerologin.php';
mysql_select_db("andaero");
$sql=mysql_query("select * from regulatory_list");
$output = new stdClass();
while($row = mysql_fetch_assoc($sql)) {
$output->Regulatory_Guidance_Library[] = $row;
}
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
echo (json_encode($output));
mysql_close();
?>
아름다운! Youve 큰 도움이되었습니다. 나는이 물건을 가져올거야. 다시 Thnx – CelticParser