Postingan lainnya
Ajax saya kenapa error ya?
<a href='https://www.facebook.com/photo.php?fbid=10207229875698861&set=a.3387077769387.2116346.1642846126&type=3&theater'>https://www.facebook.com/photo.php?fbid=10207229875698861&set=a.3387077769387.2116346.1642846126&type=3&theater</a>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="html">
<input type="button" value="Open File" onclick="openfile()">
</div>
<script type="text/javascript">
function openfile() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechage = function() {
document.getElementById('html').innerHTML = xhr.responseText;
};
xhr.open('GET','ajax.txt',true);
xhr.send();
}
</script>
</body>
</html>
0
2 Jawaban:
panggil functionya,
function openfile() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechage = function() {
document.getElementById('html').innerHTML = xhr.responseText;
};
xhr.open('GET','ajax.txt',true);
xhr.send();
openfile();
}
0