title: global variables in requireJS
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9916073/how-to-load-bootstrapped-models-in-backbone-js-while-using-amd-require-js">How to load bootstrapped models in Backbone.js while using AMD (require.js)</a>  </p>
  </blockquote>
  
  
  
  <p>This is a simple demo about my problem. </p>
  
  <p>I need to access the <code>id_user</code> in <code>main.js</code> file. My question is, how to avoid global variables in this situation? It is bad practice use global variables for this purpose?</p>
  
  <p><strong>main.js</strong></p>
  
  <pre><code>require({
      paths : {
          jQuery : 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min'
      }
  });
  
  require([ 'jQuery' ], function() {
         alert(id_user);
      });
  </code></pre>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;script data-main="js/main" src="js/require.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  function users() {
      id_user = &lt;?php echo $id; ?&gt;
  }
  
  users();
  &lt;/script&gt;
  </code></pre>