PHP Ajax Get Request Example


Share:
 | Published By: Admin | Published On: Mar 21, 2022 | Category: PHP


Hello dev,

I am going to explain you how to PHP Ajax GET Request Example. You will learn How to jQuery AJAX GET Methods example with PHP. In side this article we will see how to jQuery Ajax GET example with PHP.

This article will give you Simple Ajax request example with JQuery and PHP. We will use get simple example How to send GET AJAX request with JavaScript.

I will give you simple Example how to Ajax GET request with jQuery and PHP.

So, let's see bellow solution:

index.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>PHP Ajax Get Request Example</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
<body class="bg-dark">
    <div class="container mt-5">
        <div class="card">
            <div class="card-header">
                <h1 class="text-center">PHP Ajax Get Request Example</h1>
            </div>
            <div class="card-body">
                <h6>Content of the result will be replaced by the server date and time :</h6>
                <div id="result"></div>
            </div>
            <div class="card-footer text-end">
                <button type="button" class="btn btn-primary">Date and Time</button>
            </div>
        </div>
    </div>
</body>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $.get("date-time.php", function(data){
            $("#result").html(data);
        });
    });
});
</script>
</html>
date-time.php
<?php
    echo date("F d, Y h:i:s A");
?>
Output:

It will help you...
Share: