1

我正在尝试将我网站中的所有内容加载到具有渐变效果的 div 中,我制作了一个 jquery 函数来处理 div 内的所有点击事件,例如链接、按钮和表单提交。除了表单提交外,一切正常,例如我的一个页面中有这个表单:

<form name="form" method="post" action="">
                <p>Enter a Start date for review <font color="red"><b>(mm/dd/yyyy)</b></font>
                    :
                    <input type="text" name="StartDate" id="startDate" maxlength="10" size="15">
                    <br /> <label id="label1" style="color: red"></label>
                <p>Enter a deadline for review <font color="red"><b>(mm/dd/yyyy)</b></font>
                    :
                    <input type="text" name="txtDate" id="txtDate" maxlength="10" size="15">
                    <br /> <label id="label2" style="color: red"></label>
                </p>
                </br>
                </br>
                </br>
                <input type ="submit" name="submitCrit" value="submit"></input></br>
            </form>
            <?php
            if (isset($_POST['txtDate']) && isset($_POST['StartDate'])) { // checking if values passed
                $todays_date = date("m/d/Y"); // getting today's date to check with it
                $today = strtotime($todays_date); // parsing it to timestamp
                $to = date('Y-m-d', str_replace('-', '/', $today)); // replacing / with -
                $date = strtotime($_POST['txtDate']); // parsing enddate to timestamp
                $newdate = date('Y-m-d', str_replace('-', '/', $date)); // replacing / with -
                $startdate = strtotime($_POST['StartDate']); // parsing startdate to timestamp
                $startnewdate = date('Y-m-d', str_replace('-', '/', $startdate)); // replacing / with -
                if ($newdate != null && $newdate > $to
                        && $startnewdate != null && $startnewdate < $newdate
                        && $startnewdate > $to) {
                    $con = mysql_connect('localhost', 'root', ""); //db connection
                    if (!$con) {
                        die('connection error');
                    } else {
                        mysql_select_db("mydb", $con);
                        $query = "
                        UPDATE conference
                        SET rev_startDate = '{$startnewdate}', rev_endDate = '{$newdate}'
                        WHERE conference_id = {$confID}
                        ";
                        echo '<script type="text/javascript">'
                        , 'ChangeText("deadline set successfuly");'
                        , '</script>';

                        if (!mysql_query($query, $con)) {
                            echo "query not run";
                        }
                        mysql_close($con);
                    }
                } else {
                    echo '<script type="text/javascript">'
                    , 'ChangeText("invalid deadline");'
                    , '</script>';
                }
            }
            ?>

和这个处理点击事件的函数:

$(document).ready(function() {
               $('#mydiv').delegate('form', 'submit', function() {
                    var page = $(this).attr('action');
                    if (page == "") {
                        return true;
                    }
                    else {
                    $('#mydiv').fadeOut('slow',function() {
                    $('#mydiv').load(page, function () {
                        $(this).fadeIn('slow');
                });
                });
                return false;
                    }
          });
          return false;
          });

但是,当我单击提交时,div 中只加载了空白页面,并且 php 脚本不起作用,并且网站中的所有其他表单都会出现同样的问题。有谁知道问题出在哪里?

4

0 回答 0