简单jQuery帖子在Internet Explorer 9上不起作用(访问被拒绝)

简单jQuery帖子在Internet Explorer 9上不起作用(访问被拒绝),jquery,internet-explorer,post,Jquery,Internet Explorer,Post,我用JQuery和PHP编程了一个验证器,它可以在除InternetExplorer9之外的所有浏览器中工作。我收到错误消息“SCRIPT5:拒绝访问” jQuery代码 $('#contact-send').click(function(){ $.post('functions/db-contact.php',{ contact_name: $('#contact-name').val(), contact_email: $('#contact-email').val(),

我用JQuery和PHP编程了一个验证器,它可以在除InternetExplorer9之外的所有浏览器中工作。我收到错误消息“SCRIPT5:拒绝访问”

jQuery代码

$('#contact-send').click(function(){
  $.post('functions/db-contact.php',{
    contact_name: $('#contact-name').val(),
    contact_email: $('#contact-email').val(),
    contact_subject: $('#contact-subject').val(),
    contact_message: $('#contact-message').val()
  },
  function(x){
    console.log(x);
  }
});
这是答案(x):


1.
1.
1.
1.
诺托克
脚本5:访问被拒绝
编辑:我真的不知道会有什么错误。我添加了DB联系人文件@布拉德:)



不幸的是,我在互联网上找不到任何有用的提示。

注释掉
控制台.log
语句。在IE中,除非控制台(F12开发者工具)打开,否则会导致浏览器阻塞。

我找到了解决方案!首先,您必须更改JQuery代码。您必须对Internet Explorer使用xdr请求。这里(http://stackoverflow.com/questions/5087549/access-denied-to-jquery-script-on-ie)您可以找到关于JQuery代码端的更多信息。谢谢你!一些社区!:)


即使我不得不将PHP代码更改为发送到xdr请求的数据,以用作POST变量,我也使用了取自此页面的PHP代码:共享演示。

因此,我有100%的解决方案。
我使用的是jQuery1.6.4,而不是jQuery1.8,因此问题不再可用

我怀疑这是所有相关代码,是吗?你真的可以用你发布的代码重现这个问题吗?我添加了php文件,也许错误就在那里?:)只是猜测一下:当脚本返回false时,PHP将在HTTP响应中输入错误状态代码,IE9将该错误转换为“拒绝访问”。如果您更改
并返回false,会发生什么情况
退出?不起作用,出现相同的错误它不起作用:/第一次单击时它起作用,但第一次单击后我遇到相同的问题“SCRIPT5:…”:/因此,我有100%的解决方案。
<?xml version="1.0"?>
<response>
  <mail>
    <name>1</name>
    <email>1</email>
    <subject>1</subject>
    <message>1</message>
    <status>notok</status>
  </mail>
</response> 
SCRIPT5: Access denied
<?php
include 'db_login.php';

$name = mysql_escape_string($_POST['contact_name']);
$email = mysql_escape_string($_POST['contact_email']);
$subject = mysql_escape_string($_POST['contact_subject']);
$message = mysql_escape_string($_POST['contact_message']);

echo "<?xml version=\"1.0\"?>\n";
echo "<response>\n";
echo "\t<mail>\n";

$i = 0;
if($name == 'type your name' or $name == '' or strlen(trim($name)) == 0){
  echo "\t\t<name>1</name>\n";
  $i = 1;
}

if($email == 'type your email address' or $email == '' or strlen(trim($email)) == 0){
  echo "\t\t<email>1</email>\n";
  $i = 1;
}

if($subject == 'type subject' or $subject == '' or strlen(trim($subject)) == 0){
  echo "\t\t<subject>1</subject>\n";
  $i = 1;
}

if($message == 'type your message on us' 
  or $message == '' or strlen(trim($message)) == 0){
    echo "\t\t<message>1</message>\n";
    $i = 1;
}

if($i == 1){
  echo "\t\t<status>notok</status>\n";
  echo "\t</mail>\n";
  echo "</response>";
  return false;
}

$sql = "INSERT INTO `d013f578`.`mail` (`id`, `name`, `email`, `subject`, `message`)
       VALUES (NULL, '".$name."', '".$email."', '".$subject."', '".$message."');";
$query = mysql_query($sql) or die;
echo "\t\t<status>ok</status>\n";
echo "\t</mail>\n";
echo "</response>";
?>
            $('#contact-send').click(function(){
                if($.browser.msie && window.XDomainRequest) {
                    // Use Microsoft XDR
                    var xdr = new XDomainRequest();
                    xdr.open("POST", "functions/db-contact-xdr.php");
                    xdr.send("&contact_name="+$('#contact-name').val()+"&contact_email="+$('#contact-email').val()+"&contact_subject="+$('#contact-subject').val()+"&contact_message="+$('#contact-message').val()+""); 
                    xdr.onload = function () {
                        var dom = new ActiveXObject("Microsoft.XMLDOM");
                        dom.async = false;
                        dom.loadXML(xdr.responseText);
                        $("mail",xdr.responseText).each(function(id) {
                            var mail = $("mail",xdr.responseText).get(id);
                            }
                        });
                    };
                }else{
                    $.post('functions/db-contact.php',{
                        contact_name: $('#contact-name').val(), 
                        contact_email: $('#contact-email').val(),
                        contact_subject: $('#contact-subject').val(),
                        contact_message: $('#contact-message').val()
                    },function(x){
                        $("mail",x).each(function(id) {
                            var mail = $("mail",x).get(id);
                            }
                        });
                    });
                }
            });