Results 1 to 2 of 2

Thread: [RESOLVED] Ajax Call does not receive the return data from PHP file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2016
    Posts
    157

    Resolved [RESOLVED] Ajax Call does not receive the return data from PHP file

    Hi. This is just my learning practice, in which I've just made a simplest home.php and get.php page.
    The Call is made from home.php and the PHP code code is in get.php which is echoing a paragraph tag.


    This is my Ajax Code:
    Code:
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    
    <body>
    
        <div class="container">
    
            <div id="para">
                <button id="clickButton">click</button>
            </div>
    
            <div id="text">
    
            </div>
    
            <script src="jquery/jquery.js"></script>
            <script type="text/javascript">
                $(document).ready(function() {
    
                    $("#clickButton").on("click", function (e) {
                        debugger
                        $.ajax({
                            url: "get.php",
                            //type: "POST",
                            success: function (data) {
                                $("text").html(data);
                            }
                        });
                    });
                });
            </script>
        </div>
    
    </body>
    
    </html>
    this is get.php code:
    Code:
    <?php
    
    
    $a = "<p>This is paragraph</p>";
    echo $a;
    
    
    ?>
    Question:
    I don't receive my result in the DIV with ID text.

    I don't get any error.

    Please guide where is the mistake.

    Thank you.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2016
    Posts
    157

    Re: Ajax Call does not receive the return data from PHP file

    I've found the problem.

    My jQuery was not properly working. It was actually not loaded properly, which was making problems.

    I changed the jQuery folder name and assigned new path and it started working.

    Plus 1 more thing I found which was a missing " # " sign.

    Thank you guys.

    Thanks vbforums

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width