简单联系方式;t在没有打开IE开发人员工具栏的情况下工作


Simple Contact Form Doesn't Work without IE Developer Toolbar Open

我有一个简单的联系人表单,它适用于除IE之外的所有浏览器。只有当我打开IE的开发者工具栏(DT)时,它才能与IE一起使用。既然我不能要求人们在使用IE时按F12,有人能向我解释为什么IE如此痛苦吗。。。不喜欢这个代码吗?我不能使用开发人员工具,因为代码在运行时可以工作。

成功后的作用:您停留在同一页面上,会弹出一条消息,感谢您的提交。数据存储在数据库中,并发送电子邮件。

What IE without DT open:您重定向到.php地址,除了结果文本什么都没有。数据没有存储在数据库中,并且会发送一封包含所有信息的电子邮件,"注释"部分除外。

当然,它是从HTML开始的,一开始有一点JavaScript。。。

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
    <link rel="stylesheet" href="css/default.css" />
    <script type="text/javascript">
      $(function() {
        $('#submit').click(function() {
        $('#mbcontainerloading').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');
            var name = $('#name').val();
            var email = $('#email').val();
            var comments = $('#comments').val();
            var mathq = $('#mathq').val();
            console.log(name,email,comments,mathq); 
            $.ajax({
                url: 'submit_to_db.php',
                type: 'POST',
                data: 'name=' + name + '&email=' + email + '&comments=' + comments + '&mathq=' + mathq, 

                success: function(result) {
                    $('#response').remove();
                    $('#mbcontainerresponse').append('<p id="response">' + result + '</p>');
                    $('#loading').fadeOut(500, function() {
                        $(this).remove();
                    });
                console.log(result);
                }
            });
            return false;
        });
      });
    </script>
     </head>
      <body>
<form action="submit_to_db.php" method="post">
       <div id="mbcontainer">
        <label for="name">Name</label>
    <input type="text" name="name" id="name" />
    <label for="email">Email Address</label>
    <input type="text" name="email" id="email" />
    <label for="comments">Comments/Concerns</label>
    <textarea rows="5" cols="35" name="comments" id="comments"></textarea>
    <label for="mathq">What is 9 + 3?<br />
    <span class="mathc">(Please answer the question to prevent spam)</span></label>
    <input type="text" name="mathq" id="mathq" />
    <br />
    <input type="submit" name="submit" id="submit" value="Go!" />
    </div>
<div id="mbcontainerloading">
</div>
<div id="mbcontainerresponse">
</div>
</form>
      </body>
    </html>

当我在没有开发者工具栏(DT)的IE中提交时,我会移动到实际的.php页面。这应该在其他浏览器上起作用,就像让你留在页面上并从代码的php部分更新一样,这就是…

    <?php

    include("dogspw/dogs.inc");
    $cxn = mysqli_connect($host,$user,$passwrd,$hotel) or die ("couldn't connect to server");
    $query = "INSERT into commentsa(name, email, comments, mathq) VALUES (?, ?, ?, ?)";
if ($_POST['mathq']==12) { 
    $stmt = $cxn->stmt_init();
    echo $_POST['name']."<br />";
    echo $_POST['email']."<br />";
    echo $_POST['comments']."<br />";
    echo $_POST['mathq']."<br />";
    if($stmt->prepare($query)) {
        $stmt->bind_param('ssss', $_POST['name'], $_POST['email'], $_POST['comments'], $_POST['mathq']);
        $stmt->execute();
    }
        if($stmt) {
        echo "Thank you. We'll be in touch with you shortly!";
        } else {
        echo "There was a problem. Please try again later.";
        }
echo "...And thanks for answering the question correctly!";
}   
else {
echo "Did you answer the math question?  Your comment was not sent.";
}   
    //setup email
    $to='john@smith.com';
    $subject='Question from smith.com';
    $number=$_POST['mathq'];
    $name=$_POST['name'];
    $email=$_POST['email'];
    $questiona=$_POST['comments'];
    $message="Name:  ".$name. "'r'n" . "Email:  " .$email. "'r'n" . "Question:  " .$questiona;

    if ($number==12){
    mail($to,$subject,$message);
    echo '<br /><span style="background-color:#dfe0fc">An email has been sent to me, as well.<br />Just in case...<a href="http://www.smith.com"><span style="text-decoration: none">Go back to Smith</span></span></a>';
    }
    else 
    {
    echo '<br /><span style="background-color:#dfe0fc">An email was not sent, either.<br />
    Just in case...<a href="http://www.smith.com"><span style="text-decoration: none">Go back to smith</span></span></a>';
    }
    ?>

我已经走过了每一步,显然不知道IE需要一个调整才能运行。我已经验证了该信息是否已进入.php文件,并得到了"谢谢。我们很快就会与您联系!"的回复,不知道从这里开始该怎么办。请帮忙,我非常感谢您抽出时间,并提前感谢您。

删除console.log调用。控制台在IE中是未定义的,如果开发者工具栏是关闭的。