Jump to content

updates only after reopening browser


kvnirvana

Recommended Posts

Ive got a page with a drop down list, where a field with star rating is generated underneath depending on what is selected in the drop down list with the use of Ajax. When the user clicks on how many stars he/she wants to give , you get redirected to the front page. When the user has voted once it isnt possible to vote in the same category again. So if the user chooses the same category as just voted, it will shoq a static star rating with the values just given.

The problem is that it doesnt do that, until you have reopened the browser. So that means if you vote, and get redirected to the front page, and wants to check the category theyve just voted, it doesnt show the static star rating, but it shows the star rating as if the user hasnt voted, even though the result is saved in mysql. How do I get it to update, without reopening the browser. Dont know if its my ajax part, the redirection page, or something else I should get it to update?

What should I do?

 

Here is my Ajax part from the page jadak.php

<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").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("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","des.php?q="+str+"&navn=<?php echo $_GET['navn']; ?>"+"&pr=<?php echo $_GET['pr']; ?>"+"&id=<?php echo $_GET['id']; ?>"+"&be=<?php echo $_GET['be']; ?>"+"&om=<?php echo $_GET['om']; ?>"+"&ad=<?php echo $_GET['ad']; ?>"+"&tl=<?php echo $_GET['tl']; ?>"+"&po=<?php echo $_GET['po']; ?>",true);
xmlhttp.send("");
}
</script>

 

This is my redirecting page called thankyouforvoting.php

 

<html>
<meta http-equiv="refresh" content="4; URL=igen.php">
<meta name="keywords" content="automatic redirection">


<head>
       <title>Title here!</title>
</head>
<body>
<?php
echo "Thanks for voting";
?>
<P>
<a href="igen.php">Forside</a> 


</body>
</html>

 

And this is the code which displays the star rating from the page des.php

$sql = "select * from behan WHERE na='" . $_GET['na'] . "'and  pr='" . $_GET['q'] . "'"; 
  
or die(mysql_error());  

  
  //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><br>How many stars {$_GET['be']},  {$_GET['na']}  {$_GET['q']}?";?>	                    
                                      

  <?php  echo rating_bar($rows['id'],'6'); ?></A> <?php
      echo "</TR>";
      
          }  
             
             
             
      }      

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.