title: Use PHP code in external Javascript file
body: <p>I am just wondering if it's possible to use external JS file that contains PHP code. </p>
  
  <p>my external JS</p>
  
  <pre><code>$(document).ready(function(){
  
      $('#update').click(function(){
      var tableVal={};
      // a bit of php code I need in JS
      var search_city=&lt;?php echo $_SESSION['search_city'];?&gt;';
  $.post('&lt;?=base_url()?&gt;/project_detail/pub', {'tableVal':tableVal},function(message)
  
          })
      })
  })
  </code></pre>
  
  <p>my view page</p>
  
  <pre><code>&lt;script type="text/javascript" src="&lt;?= base_url();?&gt;js/external.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The JS doesn't work as I assume that the PHP code in JS is the problem. Any thoughts? Thanks a lot.</p>