调用php函数读取数据库时没有out


no out while calling php function to read database

我通过传递三个参数从javascript调用一个php函数,另一方面,php文件中的php函数从数据库中获取两个值并打印所有值。为此,我已经写了这段代码,但这不起作用,这意味着这段代码在输出中没有打印任何内容,所以请提供帮助。

javascript代码

jQuery.ajax(
{
    type: "POST",
    url: 'save.php',
    dataType: 'json',
    data: {functionname:'saveUser', arguments:["className", "student_id", "isPresent"]},
    success: function (obj, textstatus) {
        if( !('error' in obj) ) {
            alert(obj.result);
        }
        else {
            console.log(obj.error);
        }
    }
});

php代码

<?php
    header('Content-Type: application/json');   
    if( $_POST['functionname'] == 'saveUser' ) {
        include_once("dbConnection.inc");
        $db = db_connect();
        $newSql = "SELECT class_id, date FROM class_session WHERE class_id = (select max(class_id) from class_session)";
        $result = mysql_query($newSql, $db);
        $row = mysql_fetch_array($result);
        $class_id = $row["calass_id"];
        $date = $row["date"];
        echo json_encode(Array(
            'result' => $_POST['arguments'][0] .' '. $_POST['arguments'][1] .' '. $_POST['arguments'][2] .' '. $class_id .' '. $date
        ));
    }
?>

正确的属性是method而不是type,请参阅jQuery.ajax()

jQuery.ajax({
    method: "POST",
    url: 'save.php',
    dataType: 'json',
    data: {functionname:'saveUser', arguments:["className", "student_id", "isPresent"]},
    success: function (obj, textstatus) {
        if( !('error' in obj) ) {
            alert(obj.result);
        }
        else {
            console.log(obj.error);
        }
    }
});