使用ajax和modal添加记录

时间:2017-02-05 13:50:36

标签: javascript php jquery ajax

我想使用modal添加记录,但似乎我无法从ajax请求中获取值,

(home.php)

<?php
    require_once("class.user.php");

    $auth_user = new USER();
    //add row

    $page = isset($_GET['p'])?$_GET['p']:'';
    if($page=='add'){
        $modsubj = $_POST['subj'];
        $modsect = $_POST['sect'];  
        $modstart = $_POST['start'];
        $modend = $_POST['end'];
        $modday = $_POST['day'];
        $user_id = $_POST['user'];
        $auth_user->createSchedule($subj,$sect,$day,$strTime,$endTime,$user_id);
        $schedRow = $auth_user->readSchedule();
    }
    else if ($page == 'edit') {}

?>

(modal.funcs.php)我认为问题是变量Content-Type没有取GET值

Content-type

1 个答案:

答案 0 :(得分:0)

尝试改变 data: "subj="+modsubj+"&sect="+modsect+"&start="+modstart+"&end="+modend+"&day="+modday,

data: {"subj="+modsubj+"&sect="+modsect+"&start="+modstart+"&end="+modend+"&day="+modday},