0
사이드 바에있는 콘텐츠 목록을보고 싶습니다. 이 사이드 바에서 특정 정보를 클릭하여 내용 세부 정보를 새로 고침해야합니다.JQuery와 PHP에서의 Pb : GET과 함께 arg를 전달하여 내용을 자세히 표시
2 페이지 : test_content.php 및 test_content_detail.php. JQuery와에 의해
<?php
/*
$Id: test_content.php $
Show all content
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" charset="UTF-8" src="./js/jquery.min.js" ></script>
<script type="text/javascript">
function loadContent(id) {
var $element = $('#content');
var $response = $element.load("test_content_detail.php?id="+id+" #content_detail");
};
</script>
</head>
<body>
<div id="main">
<div id="sidebar">
<div id="items">
<div id="1" class="item">
<input type="button" value="Should show 1" onClick="loadContent(1);">
</div>
<div id="2" class="item">
<input type="button" value="Should show 2" onClick="loadContent(2);">
</div>
<div id="3" class="item">
<input type="button" value="Should show 3" onClick="loadContent(3);">
</div>
</div>
</div>
<div id="content">
<div id="content_detail">
empty
</div>
</div>
</div>
</body>
</html>
전화는 :
<?php
/*
$Id: Test_content_detail.php $
Show one content
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" charset="UTF-8" src="./js/jquery.min.js" ></script>
<script type="text/javascript">
function fillDetail(){
var html = '<br>My detail : ';
var id = "<?php print $_GET['id']?>"; // Where the PHP do the job
if (id){
html += "my id = "+id;
}
var $detail = $('#content_detail');
$detail.append(html);
};
$(document).ready(fillDetail);
</script>
</head>
<body>
<div id="main">
<div id="sidebar">
none
</div>
<div id="content">
<div id="content_detail">
supposed to be filled with <?php print $_GET['id']?>
</div>
</div>
</div>
</body>
</html>
* Test_content_detail.php ID = 3 * 올바른 것입니다. 하지만 3을 클릭하면 ""으로 채워지기로되어 있습니다.
시퀀스 pb? Thx 사전에!
은'test_content_detail.php' 또는'Test_content_detail.php'입니까? Pb는 무엇입니까? –
pb는 _test_content.php_을 실행하고 "Click 3"을 클릭 할 때입니다. 나는 "My detail : my id = 3"을 기다리고 있습니다. 하지만 _fillDetail() _ function이 그 일을하지 않는 이유를 모르겠습니다. – MLeFree