Alrighty,
I have an error module which is basically just a styled div that has a call to a PHP function for printing out errors.
It works perfectly when I include it like this:
<?php if(!empty($errors)){
include 'includes/modules/error.mod.php';
}else if(!empty($success)){
include 'includes/modules/success.mod.php';
}?>
But I am now trying to make it flashier with jQuery and so I'm including it with a jQuery function:
function errorModule(){
$.get('includes/modules/error.mod.php', function(data){
var errorModule = $(data).hide();
errorModule.appendTo($('#navMain')).show('blind', 1500);
});
}
Now, it works most of the way. The error module appears like I want it too. However the PHP function that once worked perfectly is now 'undefined.'
Why?
EDIT: Contents of error.mod.php
<div id="errorModule">
<p class="h2">The Following Errors Have Occured:</p>
<?php
echo outputArray($errors);
?>
</div>
$errorswhen the file is loaded with$.get()?$.get()requests theerror.mod.php. PHP scripts written as includes can't have a life of their own if they depend on being included server-side!