</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2013-01-09 03:10:25Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
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?
</div>
Try to add HTML tags to your PHP for example:
echo "<html><body>data.<script></script>...</body></html>"
Use any network sniffer (like FireBug, or if you using chrome the Network tab in the developer console), to see the what you get from the php, maybe there is an 404 error in your page)
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 .load
like:
$("#content").load("build.php?variable=" + a_variable, function(data) {
console.log(data); // check if you see script in the content or not
});