kvnirvana Posted May 11, 2010 Share Posted May 11, 2010 New.php is a page generated from another page. On New.php the user can choose to do a rating. If they click rating they get to Getuser.php, where there is a starrating, which works fine, but when the user clicks on the star rating bar it redirects to a blank page, which it didn’t do before, I used ajax. When a user clicked on the rating stars it said ‘thank you for voting’. I would like to know how to get this same function using ajax, or at least how to redirect to another page after clicking on the rating stars. I’m thinking it has something to do with this line xmlhttp=new XMLHttpRequest(); but honestly I don’t have a clue :=) Please help me. Thanks this is the ajax part from New.php <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("kom").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("kom").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str+"&navn=<?php echo $_GET['navn']; ?>"+"&pr=<?php echo $_GET['pr']; ?>"+"&id=<?php echo $_GET['id']; ?>",true); xmlhttp.send(""); } </script> And this is the page Getuser.php where the star rating is <?php $sql = "select * from beha WHERE navn='" . $_GET['navn'] . "'and pr='" . $_GET['q'] . "'"; //run query $result = conn($sql); if (!$result){ die("No results due to database error.<br>".mysql_error()); } if (mysql_num_rows($result)==0) { echo "No Results found!"; }else{ while ($rows= mysql_fetch_array($result)) { echo "<TR>"; echo rating_bar($rows['id'],'6'); echo "</TR>"; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.