Possible Duplicate:
Jquery load with script tags
In a PHP page I’m trying to insert some content using jquery with an onclick call into a DIV called ‘content’.
<div id="content" class="content"></div>
The version of jquery I’m calling is:
//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
When the link is clicked it calls the following javascript:
function loadA(a_variable) {
$("#content").load("build.php?variable=" + a_variable);
}
The build.php page does a few things and tries to include some text insert a javascript:
echo "Lorem ipsum dolor sit amet, consectetuer adipiscing elit";
echo "<script type='text/javascript' src='script_name.js'></script>";
echo "Lorem ipsum dolor sit amet, consectetuer adipiscing elit";
Everything works except the script is removed and doesn’t appear in my client. Any idea why this is happening and how it can be fixed?
jQuery doesn’t actually append
<script>elements to the DOM. Instead, it just evals the contents of the script. Since it isn’t in the DOM, so you cant find it, though you could check if your php echo’ed content does consist of script tag or not by checking the content obtained from.loadlike: