jQuery removing script tags
Hi,
I'm trying to load some HTML and Javascript from another document, using such code:
- var $contents = $('<div></div>').load('mydocument.html #divMainContents', function() {
- // Success callback
- alert('Value:' + $(this).html());
- });
Assuming mydocument.html #divMainContents has some DIVs and a SCRIPT tag in it, jQuery is removing the SCRIPT tag when it's displayed via the alert(). I assume this is done directly by .load(), or because it uses .html(html) to set the loaded HTML, and that method string SCRIPT tags. I've read elsewhere that this seems to be to stop Javascript executing when loaded, but this is exactly what I want it to do. Especially if I just have a function in that SCRIPT tag that I want to make available. How can I get round this problem?