我使用JQuery和PHP编写了一个验证程序,该程序适用于除Internet Explorer 9以外的所有浏览器。我收到错误消息“SCRIPT5:Access denied”。简单的jQuery发布不能在Internet Explorer 9上工作(访问被拒绝)
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):
<?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
编辑:我真的不知道有什么可以是错误。我添加了DB联系人文件。 @布拉德:)
<?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>";
?>
不幸的是,我还没有在互联网上找到任何可用的提示。
我怀疑这是所有相关的代码,是吗?只有您发布的代码才能真正重现问题? – Brad
我添加了php文件,也许错误在那里? :) – EDNA
只是一个猜测:当脚本返回false时,PHP会在HTTP响应中放入一个错误状态码,并且IE9正在将该错误转换为“拒绝访问”。如果将'return false;'改为'exit;'会发生什么? – Barmar