jQuery - ajax page load - php scope

Posted by Develman on Stack Overflow See other posts from Stack Overflow or by Develman
Published on 2010-03-09T08:00:11Z Indexed on 2010/03/09 8:06 UTC
Read the original article Hit count: 399

Filed under:
|

I am using jquery.tabs() and want to load the pages of the tabs with ajax. I am using MVC pattern with PHP and used a frontcontroller / pagecontroller pattern. The templating is done by PHP, e.g.:

<?php if($this->userLoggedIn == TRUE): ?>
    <span>Herzlich Willkommen <?php echo $this->userName; ?>!
        [<a href="logout">Ausloggen</a>]
    </span>
<?php endif; ?>

The variables ($this->userName) are injected by the pagecontroller class.

The problem is, that when I load a page via ajax, the variables are not known. Following PHP error is coming up:

Fatal error: Using $this when not in object context....

Any idea, how to use / load the variables and using it in the template files.

© Stack Overflow or respective owner

Related posts about php5

Related posts about jquery-ajax