title: Using jQuery to change PHP variable content without refresh
body: <p>I have a multi-language website – English and German.</p>
  
  <p>I have a file <code>content.php</code> in which my English and German content is stored.</p>
  
  <p>Here’s an example:</p>
  
  <pre><code>  $content_en = array(
      'title'       =&gt; 'title',
      'type'        =&gt; 'photography',
    );
  
    $content_de = array(
      'title'       =&gt; 'titel',
      'type'        =&gt; 'fotografie',
    );
  </code></pre>
  
  <p>In my <code>index.php</code> I get the values like this:</p>
  
  <pre><code>  // Checking for browser default language
    $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
  
    // Storing browser default language in variable – either `$content_en` or `content_de`
    $content_lang = ${ 'content' . '_' . $lang };
  
    // Output title in browser default’s language
    echo $content_lang['title'];
  </code></pre>
  
  <p>But I also like to have a language switcher on my site in case the browser default language is not the correct one:</p>
  
  <pre><code>&lt;button class="lang-en"&gt;EN&lt;/button&gt;
  &lt;button class="lang-de"&gt;DE&lt;/button&gt;
  </code></pre>
  
  <p>Now I’d like to change the variable <code>$lang</code> depending on which button is clicked in either <code>en</code> or <code>de</code>. The important part is: I like the values to change WITHOUT page refresh. </p>
  
  <p>I know the following code does not work like this but it literally describes what I like to achieve:</p>
  
  <pre><code>  $(' .lang-en' ).click( function( e ) {
      e.preventDefault();
      $lang = 'en';
    });
    $(' .lang-de' ).click( function( e ) {
      e.preventDefault();
      $lang = 'de';
    });
  </code></pre>
  
  <p>I am not sure if it is somehow possible (e.g. with ajax) but maybe somebody has a clue to solve my problem.</p>
  
  <p>Many thanks!</p>