sgaron Posted January 11, 2007 Share Posted January 11, 2007 I created a class that can only display in a certain div and I want to use Ajax to do the refresh function.What I did, I added an if statement after my class that takes care of the update. The javascript part works fine but the class in php gives me the following error: The script tried to execute a method or access a preoperty of an incomplete object. Please ensure that the class definition of the object "class" you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition.that is how my php files look like...index.php[code]<?phpif (!isset($_SESSION)){ session_start();}require "class.php";echo "<head><script type=\"text/javascript\" src=\"class.js\" /></head>";$_SESSION['class'] = new class();$_SESSION['class']->display();echo "<input type=button onclick='refresh('class');'>";?>[/code]class.php[code]<?phpclass class{ class(){} display(){echo "<div id=class>display</div>";} refresh(){echo "refresh";}}if ($_POST['to_refresh']){ $_SESSION[$_POST['to_refresh']]->refresh(); return;}?>[/code]What can I do to access my object without getting that error message?? Quote Link to comment https://forums.phpfreaks.com/topic/33785-classes-over-session/ Share on other sites More sharing options...
ober Posted January 11, 2007 Share Posted January 11, 2007 You cannot access the class on the starting page from the backend page. You'll need to initialize the class in the backend page. You're getting everything mixed up. Quote Link to comment https://forums.phpfreaks.com/topic/33785-classes-over-session/#findComment-158444 Share on other sites More sharing options...
sgaron Posted January 11, 2007 Author Share Posted January 11, 2007 But isnt it in the same session ?? Cause my class.js does NOT call class.php it calls index.php and index.php as the [b]if[/b] statement because of the [b]require[/b]...I'm right now creating a framework for my future app so I want everything in the class.php and class.js to be as generic as possible. And I want to have to insert the least function and code possible in the index.php for eveything to work .. I cant initialize the class in class.php because I'll be initializing more that one control anyway, thus why I chose to create a class.Any Idea on what I can do to make this work ? Quote Link to comment https://forums.phpfreaks.com/topic/33785-classes-over-session/#findComment-158454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.