Sử dụng phương thức Get
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Making GET Request using Ajax in jQuery</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("date-time.php", function(data){
// Display the returned data in browser
$("#result").html(data);
});
});
});
</script>
</head>
<body>
<!-- Mã nguồn trang date-time.php <?php echo date("Y m d h:i:s"); ?> -->
<div id="result">
<h2>Content of the result DIV box will be replaced by the server date and time</h2>
</div>
<button type="button">Load Date and Time</button>
</body>
</html>hiepsiit
Thấy bài viết hữu ích?
Ủng hộ tác giả để có thêm nhiều bài viết chất lượng nhé!