0
안녕하세요 저는 아약스의 간단한 호출이 있지만 결과를 볼 수 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까 ? 고맙습니다.간단한 아약스 게시 됨 Uncaught ReferenceError
index.php를
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function prova(SelectedFriend){
$.post("result.php", {Selected:Selected});
return false;
}
</script>
</head>
<body>
<?
$user="name1";
?>
<div onclick="prova(<? echo $user; ?>)" style="cursor:pointer;">
<? echo $user; ?>
</div>
<?
$user="name2";
?>
<div onclick="prova(<? echo $user; ?>)" style="cursor:pointer;">
<? echo $user; ?>
</div>
<?
$user="name3";
?>
<div onclick="prova(<? echo $user; ?>)" style="cursor:pointer;">
<? echo $user; ?>
</div>
<div id="Result"></div>
</body>
</html>
및 result.php
<?
echo $_POST['Result'];
?>
브라우저의 콘솔은 말한다 : 나는 이름 1을 클릭하면 "catch되지 않은 ReferenceError가 NAME1가 정의되어 있지 않습니다."
더 이상 오류가 표시되지 않지만 div에서 결과를 보는 방법 id = "결과"? 나는 $ .post ("result.php", {SelectedFriend : SelectedFriend, dataType : "html", 성공 : function (msg) {$ ("# Result") .html (msg);}})로 시도했습니다. 하지만 결과를 볼 수 있습니다. –