我的问题是这段代码:xmlhttp.open("GET","oy.php?antivirus="+y,true);
y
都是0。我选择了一个单选按钮。然后单击“投票”按钮。但没有变化。 y
始终为0.
ajax和html代码:
<script>
function send_vote()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var x;
var i;
var y = 0;
for(i = 1 ; i < 8 ; i++){
x = document.getElementById(i).checked;
if(x == true){
y = document.getElementById(i).value;
break;
}
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var a = xmlhttp.responseText;
alert(a);
}
}
xmlhttp.open("GET","oy.php?antivirus="+y,true);
xmlhttp.send();
}
</script>
<input name="antivirus" type="radio" id="1" value="1" />AVG<br />
<input name="antivirus" type="radio" id="2" value="2" />BitDefender<br />
<input name="antivirus" type="radio" id="3" value="3" />Eset<br />
<input name="antivirus" type="radio" id="4" value="4" />F-Secure<br />
<input name="antivirus" type="radio" id="5" value="5" />Kaspersky<br />
<input name="antivirus" type="radio" id="6" value="6" />McAfee<br />
<input name="antivirus" type="radio" id="7" value="7" />Norton<br /><br />
<button type="button" onclick="send_vote()" >Vote</button>
htaccess文件:
Options +FollowSymlinks
DirectorySlash Off
RewriteEngine On
RewriteRule ^([a-z0-9\-\_]+)$ index.php [L,NC]
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)$ index.php [L,NC]
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-z0-9\-\_]+)$ index.php [L,NC]
答案 0 :(得分:0)
添加一些条件,这样就不会重写现有文件或目录:
Options +FollowSymlinks
DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9\-\_]+)$ index.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)$ index.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-z0-9\-\_]+)$ index.php [L,NC]