Reputation: 6073
I want to load some HTML which include a bit of javascript, using jQuery. I've tried using both load() and ajax(). The HTML is inserted nicely into the DOM, but any script-tags seems to be filtered out. If I alert() the returned HTML, the scripts are included, but when i use html() or append(), the scripts are missing.
Any ideas?
Upvotes: 2
Views: 777
Reputation: 342695
You should use $.getScript
to load and execute remote Javascript:
Loads, and executes, a local JavaScript file using an HTTP GET request.
Example:
$.getScript("test.js", function(){
alert("Script loaded and executed.");
$('#myDiv').load('some.html');
});
Upvotes: 3
Reputation: 8766
try using:
$.get("url.php",{param1:'1',param2:'2'},function(result)){
$('#somediv').html(result);
}
p.s. please use the latest jquery version
Upvotes: 0