I have the following function:
function loader($time,$page){
echo "<script type='text/javascript'>
$( document ).ready(function() {
$('.register-container').hide();
$('.top-color').animate({height:'100%'}, 500);
window.setTimeout(
function() {
$('.loading-overlay').show();
},
600
);
//Simulate loading... and then redirect.
window.setTimeout(
function() {
$('.loading-overlay').hide();
$('.top-color').animate({height:'0px'}, 500);
},
2600
);
});
</script>";
echo '<div class="loading-overlay" >
<div class="loading-circles">
<!-- MAINTAINS CONSISTANT COLOR CENTER -->
<div class="circle hold" ></div>
<!-- ITERATION POINT FOR ANIMATION -->
<div class="circle first"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<!-- ICON -->
<div class="name"><img src="images/loader/loadertext-green.png" /></div>
</div>';
echo "<meta http-equiv=refresh content=$time;URL='$page'>";
}
Which should add the above jQuery code to the page, and execute it.
Now my problem is, that when the function is called in the page, like below:
<?php
if($checksuccess){ loader("4","/account"); }
?>
I get the following jQuery error:
Uncaught ReferenceError: $ is not defined
What am I doing wrong?