I basically just want to append a javascript variable to an HTML div with JQuery. However I need to append some PHP code as a string, it doesn’t need to execute it just needs to show up as a plain old string string.
The following code doesn’t seem to append because I think it is still recognized as PHP syntax.
var script = '<?php wp_list_pages(); ?>';
divName.innerHTML = script;
Any help would be much appreciated.
Just a guess… replace the php brackets with HTML entities (< and >) so it will not be interpreted as PHP code (if you run the file containing the JS through PHP) nor as strange HTML code (the browser searches for brackets as html tags, remember…) by the browser.