jQuery .load() call doesn't execute JavaScript in loaded HTML file

后端 未结 13 1712
难免孤独
难免孤独 2020-11-22 08:28

This seems to be a problem related to Safari only. I\'ve tried 4 on Mac and 3 on Windows and am still having no luck.

I\'m trying to load an external HTML file and

13条回答
  •  情歌与酒
    2020-11-22 08:56

    A other version of John Pick's solution just before, this works fine for me :

    jQuery.ajax({
       ....
       success: function(data, textStatus, jqXHR) {
           jQuery(selecteur).html(jqXHR.responseText);
           var reponse = jQuery(jqXHR.responseText);
           var reponseScript = reponse.filter("script");
           jQuery.each(reponseScript, function(idx, val) { eval(val.text); } );
       }
       ...
    });
    

提交回复
热议问题