안녕하세요^ ^ 처음으로 질문 남겨봅니다
생활코딩의 강좌를 보면서 ajax 통신을 이해해 보고 있는데요
javaScript - Ajax (2/3) : 기본 동작 방법 강좌
https://opentutorials.org/module/904/6843
에 나오는 예제에서 궁금한게 생겼습니다
demo1.html
<p>time : <span id="time"></span></p>
<input type="button" id="execute" value="execute" />
<script>
document.querySelector('input').addEventListener('click', function(event){
var xhr = new XMLHttpRequest();
xhr.open('GET', './time.php');
xhr.onreadystatechange = function(){
if(xhr.readyState === 4 && xhr.status === 200){
document.querySelector('#time').innerHTML = xhr.responseText;
}
}
xhr.send();
});
</script>
time.php
<?php
$d1 = new DateTime;
$d1->setTimezone(new DateTimezone("asia/seoul"));
echo $d1->format('H:i:s');
?>
demo1.html 에 time.php 의 내용을 출력하는 예제입니다
궁금한 점은 demo1.html에 ajax 코드에서 아래 함수의 인자입니다
function(event) 함수에 들어오는 event인자가
time.php에서 출력한 echo $d1->format('H:i:s');
값을 넘겨 받는 것 인가요?
아니면 'click' 이벤트를 받아서 함수를 실행하라는 명령이 들어오는 건가요?
감사합니다 ^ ^