2012-01-09 59 views
0

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

成功时的功能:您将保持在同一页面上,并弹出一条消息,感谢您的提交。数据存储在数据库中并发送电子邮件。

没有打开DT的IE:您重定向到.php地址,并且没有任何内容,只是结果文本。数据不会存储在数据库中,并且电子邮件会与所有信息一起发送,“评论”部分除外。

当然它在一开始有点JavaScript的HTML开始了...

<!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> 

当我在IE浏览器没有提交开发人员工具栏(DT),我搬到了实际的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='[email protected]'; 
    $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文件,并得到“谢谢你,我们会很快与你联系!”的回复。不知道该从哪里出发。 请大家帮忙,我非常感谢你的时间,并且提前感谢你。

回答

2

删除console.log调用。如果开发人员工具栏已关闭,则控制台在IE中未定义。

+0

现货!万分感谢! – Jaspers 2012-01-09 06:55:18

相关问题