Reputation: 72
I have a an script that sends a post to my php file:
$('.target').change(function() {
$.ajax({
type: "POST",
url: "/form-actions.php",
data: {rechten : '0'},
cache: false,
success: function(){
alert("Submitted");
}
});
});
When i use firebug i can see the post being send: Parameter: rechten 0
But my form-actions.php (which is in the right location) can't see the post when i use
<?php print_r($_POST); ?>
The outcome of this is Array ( )
What am i doing wrong?
Thank you for your time!
Upvotes: 0
Views: 969
Reputation: 16953
(I'm adding this as an answer rather than a comment because of the code) Are you super-sure your php file is in the right place? Change your JS to
$('.target').change(function() {
$.ajax({
type: "POST",
url: "/form-actions.php",
data: {rechten : '0'},
cache: false,
success: function(data){
alert(data);
}
});
});
And see what is alerted.
This is assuming that form-actions.php contains just
<?php
print_r($_POST);
?>
and nothing else (or you'll see that too).
Upvotes: 1