변수 $pos
에는 내가 누른 제출 버튼 이후에 값이 없습니다.Ajax가 GET을 사용하여 PHP에 변수를 넘김
<?php
$pos = $_GET['pos'];
echo "<br><br>pos = ".$pos;
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=us-ascii">
<title></title>
<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){
var position = 128;
$('#submit').click(function(){
$.ajax({
type:"GET",
url: "ajax_test.php",
data: { pos : position },
success: function(){
//do stuff after the AJAX calls successfully completes
}
});
});
});
</script>
</head>
<body>
<br>
<button id="submit">Submit</button>
</body>
</html>
FF의 웹 콘솔을 보여줍니다
[12:41:55.027] GET http://somehost.com/ajax_test.php?pos=128 [HTTP/1.1 200 OK 187ms]
# 제출 유형의 입력이 제출되고, 예를 들어
appendTo()
와 jQuery를 사용하여 데이터를 삽입 할 수 있습니다, 맞습니까? 그리고 그것은 양식의 내부에 위치합니다, 맞습니까? –$ pos가 정의되지 않았습니다. 정의 된 위치 만 –
HTTP 프로토콜, 요청 및 응답 및 사용 방법에 대해 알아야합니다. 모든 것이 곧바로 진행됩니다. – moonwave99