tdphp/tdajax/index.php
2023-03-22 00:13:04 -07:00

39 lines
No EOL
970 B
PHP

<!DOCTYPE html>
<html>
<head>
<title>JSON Content</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
setInterval(function() {
$.ajax({
url: "showDate.php",
dataType: "json",
success: function(data) {
$("#json-content").text(JSON.stringify(data));
}
});
}, 1);
});
$(document).ready(function() {
$("#myInput").on("input", function() {
$.ajax({
url: "write.php",
method: "POST",
data: {
content: $(this).val()
}
});
});
});
</script>
</head>
<body>
<div id="json-content"></div>
<input type="text" id="myInput">
</body>
</html>