Passing over variables from a file to another using jQuery/AJAX shows empty result : <p>I want to fetch the list of transactions through jQuery/AJAX so it will update on any page I have that list on, when I update the content of this file I want to use. But I don't want to have the SQL queries in the file that I get through jQuery/AJAX since I use different queries for different pages on my website.</p>

<ul>
<li>The file <strong>transactions.php</strong> contains all the SQL queries that I need. In that file, I also have this line: <code>&lt;div id="transactions"&gt;&lt;/div&gt;</code>.</li>
<li>The file <strong>fetch-transactions.php</strong> contains this list I want to show on the page. In it I have 2 globals (you know, <code>global $thevariable</code>) for 2 required variables (<code>$count_transactions</code> (to count the transactions) and <code>$get_transactions</code> (to loop the transactions into the list)) that can be found in transactions.php.</li>
<li>The <strong>javascripts.js</strong> contains all the needed JavaScript codes I have for my website, including this line: <code>$.get(folder_name + 'ajax/fetch-transactions.php', function(s) { $('div#transactions').html(s); });</code></li>
</ul>

<p>As you maybe already have figure out, <strong>s</strong> contains the content of <strong>fetch-transactions.php</strong>.</p>

<p>The thing is that none of the variables I have set globally in <strong>fetch-transactions.php</strong> have any data in them. The are empty! Why is that? Is it because they are not globally set? I don't want to use <code>define</code> as a variable. I don't think that is even possible for fetching data from the database :P</p>

<p>How can I fix this problem?</p>
