【发布时间】:2014-03-03 16:43:47
【问题描述】:
我的问题是这个代码: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]
【问题讨论】:
-
oy.php将匹配您的第一个重写规则并被重写为 index.php -
我验证了 JavaScript 代码有效。所以这可能就像 Marc 所说的那样。见:jsfiddle.net/b6ees/1
-
我不明白。你能解释和写代码吗?
-
如何匹配第一个重写规则?