javascript - Reload page after click on <a> to get new data from PHP -


i'm writing multilingual web , logic next:

  1. by default there "lang.tmp" file default data "eng".
  2. when index.php loads takes data "lang.tmp" , sets default language loading data lang.php:

    include("lang/".file_get_contents("lang.tmp").".php"); 
  3. if user wants change language, clicks on link created php, rewrites data in "lang.tmp":

    include("lang/languages.php"); $i=0; while (list($key, $value) = each($languages)) {     echo '<li class="lang"><a href="index.php?'.$key.'"><div id="langbox">'.$value.'</div></a></li>';     if ($_server['query_string'] == $key)     {         $fp=fopen("lang.tmp","w");         fwrite($fp,basename($key));          fclose($fp);     } 

    so! problem is: after rewriting "lang.tmp" file need reload page same "index.php" address new type of language.

  4. i've tried

    header("location: index.php");  

and doesn't work because url same, i'm getting error:

warning: cannot modify header information - headers sent. 
  1. i tried javascript:

    $("div #langmenu").click(function() {         location.reload();         console.log ("clicked!"); });  

but doesn't worked either. page reloads new language after second click on link, that's not needs ))

would kind link i'm wrong or other options reload page in situation.

  1. the header redirect should work, error means text has been shown (you can make call when page loading, not once you've sent content).
  2. the logic flawed in single user change language entire site.
  3. why not make <a> link page in first place?

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -