Q:

Loaded PHP file cannot access parent file's classes

I have the index.php in the root folder, Homepage_top.php and Homepage_bottom in View Folder, and some PHP files  classes in folder Model. Index.php includes Homepage_top.php and files from Model folder
require('Model/Database.php');
require('Model/StoryCategory_model.php');
require('Model/StoryCategory_db.php');
require('Model/User_model.php');
require('Model/User_db.php');
require('Model/StoryType_model.php');
require('Model/Story_db.php');
require('Model/Story_model.php');
include('View/Homepage_top.php');

In Homepage_top.php, I use $.load to include Homepage_bottom.php
$(".stories").load("View/Homepage_bottom.php", {myQuery: myFinalSQL, action: "show_all_stories_sorting"});

Error occurs, saying it cannot find classes (.i.e. story class in Story_model.php) in Homepage_bottom.php. Would you please tell me why this happens and how to fix it? I thought I already provide all the necessary classes in the index.php. Thank you so much.

A:

Loading files through jQuery inside a page doesn't means that the precessor code is already included in the file. You must be sure if your file "View/Homepage_bottom.php" has the necessaries includes.

