POST data not passed from AJAX to PHP file

0 views
0

As a test on click I send this from jQuery:

$(document).ready(function() {
    /* Updated new Item */
    $(".CRUD-update").click(function(e) {
        var form_action = $("#update-user").find("form").attr("action");
        alert("HERERERERE");
        $.ajax({
            type: 'POST',
            url: url + form_action,
            data: {
                test: 'Hi there!'
            },
            success: function(data) {
                alert(data);
                toastr.success('Item Updated Successfully.', 'Success Alert', {
                    timeOut: 5000
                });
            }
        });
         alert("End"); /*Just added. Shouldn't this fire when it is done?*/
    });
});

To this php script

<?php
   if(isset($_POST['test'])){
       echo "TEST ".$_POST['test'];
   }
   echo "NOT SET";
   echo "USERID ".$_SESSION['user_id'];
}
?>

I get no POST data. The alert fires in the jQuery file and my PHP file gets the redirection, just no POST data.

It has been driving me crazy for a couple of days. Any one have any ideas?

Tim