我运行ajax后无法从php获得响应

时间:2019-04-12 11:32:10

标签: php jquery ajax

我正在使用jQuery和PHP记录评论。 jQuery部分工作正常,但我无法使PHP准备记录注释。 jQuery发送后返回警报200,但我认为我无法在PHP中访问“类”。

PHP:

class comments extends config{
    public function Action2($id,$comment){
        //record comment
    }
}

$input=json_decode(file_get_contents('php://input'));
$new_comment=new comments();
$new_comment->Action2($input->id,$input->comment);

jQuery:

$.ajax({
    url:'./comment.php',
    type:'POST',
    dataType:'json',
    cache:false,
    contentType:false,
    processData:false,
    data:JSON.stringify({
        'comment':comment,
        'id':id
    }),
});

0 个答案:

没有答案