<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<script>
function test_go(data) {
var Value = data.innerText;
// alert(Value); //test
$.ajax({
type: 'GET',
url: 'ajaxtest.php',
data: {"send_data":Value},
error: function(){
alert('받기 실패');
},success: function() {
alert('받기 성공');
}
});
}
</script>
<?php
echo "<script>console.log('들어옴');</script>";
$_getData = $_GET['send_data'];
echo $_getData;
?>
<body>
<div onclick="test_go(this);" style="border:1px solid blue;" value="test">test</div>
</body>
</html>
div 클릭시 js에서 php 로 보낸 Value 데이터를 출력하고 싶습니다.
제가 알기론 서버단은 먼저 실행되는 걸로 아는데 div눌러도 php를 호출하지 않습니다.
방법 부탁드립니다. 감사합니다.