ajax php javascript页面打开,未传递参数

ajax php javascript页面打开,未传递参数,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我在将一些值传递到php页面时遇到问题,不知道有什么问题,只知道错误发生在xmlhttp.open。我试了很多东西,但都想不出来 代码如下: html: 函数getVote(i,j){ if(window.XMLHttpRequest){//IE7+、Firefox、Chrome、Opera、Safari的代码 xmlhttp=新的XMLHttpRequest(); }else{//IE6、IE5的代码 xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);

我在将一些值传递到php页面时遇到问题,不知道有什么问题,只知道错误发生在xmlhttp.open。我试了很多东西,但都想不出来

代码如下: html:


函数getVote(i,j){
if(window.XMLHttpRequest){//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}else{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
document.getElementById(“poll”).innerHTML=xmlhttp.responseText;
}
}
open(“GET”、“poll_vote.php?vote1=“+i+”&vote2=“+j,true”);
xmlhttp.send();
//文件。写(i+“”+j);
}
你是滑雪者,还是在滑雪板上变胖了?不管怎样,让我们看看是否撕碎。。。
你是做什么的?
滑雪板:
滑雪板:
梦想获得rad:
你看别人先跳吗?
对:
否:
和php:

<?php
$vote1 = $_REQUEST['vote1'];
$vote2 = $_REQUEST['vote2'];
$filename = "poll_result.txt";
$content = file($filename);    
$array = explode("||", $content[0]);
$ski = $array[0];
$board = $array[1];
$no = $array[2];
$radski = $array[3];
$radboard = $array[4];
if ($vote1 == 0) {
    $ski = $ski + 1;
} else if ($vote1 == 1) {
    echo "howdyyy";
    $board = $board + 1;
} else if ($vote1 == 2) {
    $no = $no + 1;
}
if ($vote2 == 0) {
    if ($ski == 1) {
        $radski = $radski + 1;
    } else if ($board == 1) {
        $radboard = $radboard + 1;
    } else if ($no == 1) {
    }
    $no = $no + 1;
} else if ($vote2 == 1) {
}
$insertvote = $ski."||".$board"||".$no"||".$radski"||".$radboard;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Result:</h2>
<table>
<tr>
<td>Skiers:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($ski/($ski+$board+$no),2)); ?>'
height='20'>
<?php echo(100*round($ski/($ski+$board+$no),2)); ?>%
</td>
</tr>
<tr>
<td>Snowboarders:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($board/($ski+$board+$no),2)); ?>'
height='20'>
<?php echo(100*round($board/($ski+$board+$no),2)); ?>%
</td>
</tr>
<tr>
<td>Dreamers:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($no/($ski+$board+$no),2)); ?>'
height='20'>
<?php echo(100*round($no/($ski+$board+$no),2)); ?>%
</td>
</tr>
<tr>
<td>Rad Skiers:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($radski/($ski+$board+$no),2)); ?>'
height='20'>
<?php echo(100*round($radski/($ski+$board+$no),2)); ?>%
</td>
</tr>
<tr>
<td>Rad Snowboarders:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($radboard/($ski+$board+$no),2)); ?>'
height='20'>
<?php echo(100*round($radboard/($ski+$board+$no),2)); ?>%
</td>
</tr>
</table>

结果:
滑雪者:
'
高度class='20'>
%
滑雪板运动员:
'
高度class='20'>
%
梦想家:
'
高度class='20'>
%
滑雪者:
'
高度class='20'>
%
Rad滑雪板运动员:
'
高度class='20'>
%
和txt文件,如:

0 | 0 | 0 | 0 | 0 | 0

这就像是w3schools上的一个示例,但我是新手,仍在学习,很好奇为什么我的代码现在不起作用

感谢所有的帮助

享受

好的,有bug了

将PHP文件第30行中的代码替换为:

$insertvote = $ski."||".$board."||".$no."||".$radski."||".$radboard;
您遗漏了
(追加)符号

这是我得到的输出。忽略网络错误(我没有图像)


希望有帮助

您是否考虑过使用jQuery或Zepto之类的工具来处理ajax?对于单个请求来说,这需要很多代码。如果你做了很多这样的请求,你最好使用一个经过良好测试并证明能在多种浏览器中工作的库。有点,但我只是在学习,wana会处理所有的过程,从头开始。您可能应该首先阅读本文。当您尝试执行请求时,您是否能够查看开发人员的控制台?只需知道错误发生在xmlhttp.open。您到底遇到了什么错误?假设这是
404未找到
非常感谢,我不敢相信,但我不确定,我对php还是新手,我的眼睛还没看准
$insertvote = $ski."||".$board."||".$no."||".$radski."||".$radboard;