0
retun 호출에 필요한되지 않고 무엇을 보여줄 방법 :내가 내의 index.php에있는 전체 페이지
<?php
$sContent.='<script src="https://code.jquery.com/jquery-1.12.4.js"></script>';
$sContent.='<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>';
$sContent.='<script src="in.js" type="text/javascript"></script>';
$id=2;
$sContent.='<div id="agree">Agree to terms: <input type="checkbox" id="agreed" value=1></div>';
$sContent.='<br><br><div class="show"></div>';
if($_GET['f'] == 'showInfo')
{
$sContent.= 'This is the info about item id: '.$_GET['id'];
}
$sAction = $_SERVER['PHP_SELF']."?id=".$id."&f=showInfo";
$sDest.= '<br><input class="'.$id.'" type="button" id="'.$id.'" name="'.$id.'" value="Click to show info about item '.$id.'" onClick="javascript:showInfo(\''.$sAction.'\');">';
$sContent.= $sDest;
echo $sContent;
?>
그리고 내 JS 파일을 :
function showInfo (action)
{
var aryAction = action.split('?');
params = aryAction[1];
var theUrl = 'index.php';
alert(aryAction[1]);
$.ajax ({
url: theUrl,
data: params,
async:true,
success: function (data, textStatus)
{
$('.show').html (data);
}
});
}
이 전체 인덱스를 보여줍니다 'show'클래스의 div 안에 .php. 나는 그저 div, 그 밖의 것은 아무것도 없다. 단지 'This is item id : 2'에 대한 정보가 필요하다.
나는 다른 비슷한 게시물을 읽고 있었고 어쩌면 어떻게 해야할지 아약스 기능을 사용해서는 안된다.
감사합니다.
당신은 당신이 원하는 것만을 반환하는 PHP를 변경할 수 없습니다? 또는 jQuery를 사용하여 전체 페이지를받은 후에 만 해당 섹션을 추출해야합니다. – charlietfl