답변 3개 / 댓글 1개
채택된 답변
+20 포인트
ajax는 정말 쉽습니다.
참고: https://www.w3schools.com/xml/ajax_intro.asp
Copy
ajax_test.html
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<h2>Let AJAX change this text</h2>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "ajax_info.php", true);
xhttp.send();
}
</script>
</body>
</html>
ajax_info.php
<?php
echo "message";
?>
이게 답니다. 저도 늘 복사해서 봍여넣기 해서 사용합니다.
답변을 작성하려면 로그인이 필요합니다.