Récupérer et exécuter script
Bonjour,
Je récupère une page Web en AJAX comme ceci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| $.ajax({
url: "toto.html",
type: "GET",
dataType: "html",
cache: false,
//timeout: myOptions.timeout,
error: function(jqXHR, textStatus, errorThrown){
alert("error");
},
//data: postStr,
success: function(data){
//alert("success");
var $div = $("<div>").append($.parseHTML(data));
$("#myDiv1").html($div.find("#myDiv2").html());
}
}); |
Page "toto.html"
Code:
1 2 3 4 5 6 7 8 9
| <div id="myDiv2"></div>
Hello
</div>
<script type="text/javascript">
function foo(){
alert("hello world !");
}
</script> |
Est-il possible à la réception de ma requete AJAX, d'executer la fonction foo ?
=> je ne vois pas comment récupérer/executer le script
Merci d'avance,