Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts

    $.post function: PHP is not parsing my script

    I am trying to get a simple Ajax call to a PHP file to work using jQuery’s $.post() function, like so:

    PHP Code:
    $(function() {
        $(
    "#postbtn").click(function () {
            $.
    post("timercomplete.php", {id12345}, function (data) {
                
    alert ('data is ' data);
            }, 
    "text"); 
        });
    }); 
    My timercomplete.php script is simple:

    PHP Code:
    <?php
    header
    ("Cache-Control: no-cache"); 
    foreach (
    $_POST as $val) {
        echo 
    "$val\n";
    }
    ?>
    My alert box pops up with the exact text that’s in the PHP file—in other words, the timercomplete.php script is not getting parsed by PHP, but rather it’s just sending its contents back to the $.post callback function. What could be causing this?

    I’m running this using WAMPP lite… PHP is working fine for normal PHP pages, and the $.load function is parsing PHP fine, just not $.get or $.post.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Nevermind this post, I was not in my right mind. I had loaded the page straight from my Windows file system rather than through the web server (127.0.0.1). Argh. Bleck. Attention to detail, Mr. Fumigator, attention to detail.


  •  

    Posting Permissions

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