I have a variable set in my main file (main.php), and need the second file (uploads.php) to reference the variable as it is set in the first file. It is returning undefined right now tho.
The second file is loaded with $.load into the first file: code example below -
Main.php Contents:
<?php $accountName = get_option('account_name'); ?>
<div id="uploads"></div>
<a href="#" onclick="loadUploadsFile()">Load Your Playlist</a>
function loadUploadsFile() {
jQuery('#uploads').load('uploads.php');
}
Uploads.php file contents
<?php echo $account_name; ?> <== returns undefined
$url = 'http://www.somewebsite.com/' . $accountName . '/page/'
/* more code below running a query/loop etc. */
As you may be able to tell, I want Uploads.php to reference the variable decleration in Main.php but is is not pulling the value, it is just returning undefined. Uploads.php loads into the uploads div, but without the account name set the content is just blank.
Would I need to pass the variable to Uploads.php through ajax? I've tried session variables but couldn't get that to work. I was trying an ajax request but I am new to it so couldn't get that nailed. Any help would be great.