0

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!

4

1 回答 1

1

(由于代码,我将其添加为答案而不是评论)您是否非常确定您的 php 文件位于正确的位置?将您的 JS 更改为

$('.target').change(function() {
    $.ajax({
        type: "POST",
        url: "/form-actions.php",
        data: {rechten : '0'},
        cache: false,
        success: function(data){
            alert(data);
       }
    });
});

看看有什么警报。

这是假设 form-actions.php 只包含

<?php
print_r($_POST);
?>

没有别的(或者你也会看到)。

于 2013-07-04T12:26:56.127 回答