0

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.

gturri
  • 13,807
  • 9
  • 40
  • 57
  • Learn to use an [autoloader](http://php.net/manual/en/function.spl-autoload.php) – Mark Baker Dec 26 '14 at 20:01
  • you are including bottom file in top file and then access parent class from the bottom file, how is it possible? you need to include the files in which you want to access the class. Your question is quite confusing, rather post all the file codes – Pavan Jiwnani Dec 26 '14 at 20:01
  • But if you're using `$.load ` to load the `View/Homepage_bottom.php` from your javascript, then it's a new request against the webserver.... `index.php` doesn't even enter the equation.... there is no "parent" file – Mark Baker Dec 26 '14 at 20:03

1 Answers1

0

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.

mend3
  • 506
  • 4
  • 15