tdphp/tdajax/index.php

39 lines
970 B
PHP
Raw Normal View History

2023-03-22 08:13:04 +01:00
<!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>