This question is unique because the error
ReferenceError: $ is not defined comes from the fact that javascript is called in the header but the jQuery is looking inside the parent iframe and don't find it.
I got this page:
review.php
<?php include 'review_core.php'; ?>
<div id="primary" class="content-area col-md-9">
<main id="main" class="post-wrap" role="main">
<?php include 'review_index.php'; ?>
</main><!-- #main -->
</div>
<?php get_sidebar();
get_footer(); ?>
in review_core.php
I got some php that fetch folders, images and other things from a S3 bucket, and in review_index.php
I got some html and php to show up the data runned by review_core.php
inside (a lot) some divs.
The get_sidebar();
just get the wordpress sidebar where I have an Iframe and here is where the problem is coming. In this iFrame is runned a php script (some_php_in_frame.php
) that when ends should reload the #primary div, so basically it have to reload review_index.php
into it. I'm tring to do it by adding this code at the end of some_php_in_frame.php
:
some_php_in_frame.php
<?php [...] ?>
<script>
$(document).ready(function(){
parent.location.href=parent.location.href;
$('#primary').load('review_index.php');
})
</script>
but the refresh don't work and as results in debug I get:
ReferenceError: $ is not defined