$.ajax()는 본인페이지에서 값을 가져(?)올 수는 없나요?

$.ajax()는 본인페이지에서 값을 가져(?)올 수는 없나요?

QA

$.ajax()는 본인페이지에서 값을 가져(?)올 수는 없나요?

답변 2

본문

form action 으로 자기 페이지 적어서

값을 받아올 수는 있잖아요?

 

아래의 페이지가 test.php 라고 했을 때,


 
<?php
include_once ('./_common.php');
include_once (G5_PATH.'/head.php');
?>
<script type="text/javascript">
$(document).ready(function(){
    var idx = "19";
    $.ajax({
        url: "test.php",
        method: "post",
        dataType: "json",
        async: false,
        data: {idx: idx},
        sucess: function(data){
            console.log(data);
        }
    });
});
</script>
<button type="button">버튼</button>
<?php
$idx = $_POST['idx'];
echo json_encode($idx);
?>

<?php
include_once (G5_PATH.'/tail.php') ;

 

위에 처럼 쓰면 작동을 안 하나요?

 

이 질문에 댓글 쓰기 :

답변 2

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
filter #ajax ×
전체 407
© SIRSOFT
현재 페이지 제일 처음으로