jqery에는 $.post()라는 메소드가 있습니다. 다음은 이 메소드의 간단한 예입니다.
제목 없는 문서
<script><BR>checkemail(){<br><br> if($('#email') .val( ) == ""){<BR> $('#msg').html("이메일을 입력하세요!");<BR> $('#email').focus;<BR> return false ;<BR> }<BR> if($('#address').val() == ""){<BR> $('#msg').html("주소를 입력해주세요!");<BR> $ ('#address').focus;<BR> return false;<BR> }<BR> ajax_post();<BR>}
<P>함수 ajax_post(){<BR> $.post("action.php",{email:$('#email').val(),address:$('#address').val()} ,<BR> function(data){<BR> //$('#msg').html("이메일을 입력해주세요!");<BR> //alert(data);<BR> $('# msg').html(data);<BR> },<BR> "text");//여기에 반환된 유형은 다음과 같습니다: json,html,xml,text<BR>}<BR></script>
$email = $_POST["email"];
$address = $_POST[" 주소"] ;
//echo $email;
//echo $address;
echo "success";
?>
버튼을 클릭하면 현재 버튼 유형이 버튼이라는 점에 유의하세요. $.post() 메소드를 사용하지 않을 경우 버튼 유형은 submit 입니다. form을 작성하고 post 메소드를 사용하여 이를 페이지 action.php에 전달한 다음 전달된 데이터를 페이지 action.php에서 수신할 수 있습니다. $.post 메소드를 사용할 때 실제로는 ajax_post() 메소드에서 post 메소드를 사용합니다. (jquery 라이브러리 파일을 인용하려면)