1

I have this code:

$("#tab").load(path/to/php_file);

I get this error when executing:

Fatal error: Call to undefined function _e() in ... on line 4

Part of the content of this php file:

<div class="cell_wrapper">
<div class="cell">
    <div class="cell_inner">
        <label><?php _e("Use playlist selector:", "domain"); ?></label>
    </div>
    <div class="cell_inner">
        <input type="checkbox" class="usePlaylistSelector">
    </div>
</div>
....

It works well if I include this php file like this:

<div id="tab">
    <?php require_once(path/to/php_file); ?>
</div>

I have several big php files which I need to include on demand (when I need it).

Is this something that can be solved or I have to take another approach?

Toniq
  • 4,492
  • 12
  • 50
  • 109
  • 3
    First the error message should be obvious enough. The function is not defined. You must define it before using it, weather that be in an include or the same file itself. – Robert Aug 09 '16 at 01:41
  • 2
    When requiring a file in PHP, the content is just inserted at that point, and can use functions defined up to that point. When using ajax, there's no such thing, the PHP script you're calling must stand on it's own, and can't rely on variables that no longer exist. – adeneo Aug 09 '16 at 01:47

0 Answers0