PHP how come global variable does not work when utlizing ajax to fetch content? -
so have code snippet.
function get_box_ajax() { global $box; $box = get_box(); // creates box object ob_start(); get_template( '/filepath/content.php' ); $output = ob_get_clean(); } // in content.php file global $box; <form action="<?php echo box_url( $box->url ); ?>" method="post"> // error on line ... </form>
so code, getting non-object error on call $box->url. take note done via ajax.
so thought in ajax function have globalized $box , take doesn't seem work? thoughts?
two things:
when get_box_ajax
function called? , function get_box
do? both things relevant.
i don't think problem whether box
global or not (which is), rather if url
variable of box
being defined or if box
being initialized @ all.
Comments
Post a Comment