ajax php javascript php page open, parameters not being passed -


i having trouble pass values php page, don't know whats wrong, know error occurs @ xmlhttp.open. tried lots of stuff, cant figure out.

heres code: html:

<html> <head> <script> function getvote(i, j) {      if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari         xmlhttp=new xmlhttprequest();     } else {// code ie6, ie5       xmlhttp=new activexobject("microsoft.xmlhttp");     }     xmlhttp.onreadystatechange = function() {         if (xmlhttp.readystate==4 && xmlhttp.status==200) {             document.getelementbyid("poll").innerhtml=xmlhttp.responsetext;         }     }     xmlhttp.open("get","poll_vote.php?vote1="+i+"&vote2="+j,true);     xmlhttp.send();     //document.write(i + ' ' + j); } </script> </head> <body> <div id="poll"> <h3>are skier, or stout on board mon? either way, lets see if shred...</h3> <form> do?<br> ski: <input type="radio" name="vote1" id="vote1" value="0" > <br>snowboard: <input type="radio" name="vote1" id="vote1" value="1"> <br>dream of getting rad: <input type="radio" name="vote1" id="vote1" value="2"> <br> watch other people hit jump first?<br> yes: <input type="radio" name="vote2" id="vote2" value="0" onclick="var tmpora = document.getelementbyid('vote1').value; getvote(tmpora, this.value);"> <br>no: <input type="radio" name="vote2" id="vote2" value="1" onclick="var tmpora = document.getelementbyid('vote1').value; getvote(tmpora, this.value);"> <br> </form> </div> </body> </html> 

and 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> 

and txt file like:

0||0||0||0||0

this sample on w3schools new , still learning , curious why code isn't working now.

thanks help!!

enjoy

ok, got bug.

replace code in line 30 in php file this:

$insertvote = $ski."||".$board."||".$no."||".$radski."||".$radboard; 

you had missed out .(append) symbol.

this output got. ignore network error( dont have images)

enter image description here

hope helps!.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -