看到关于jQuery.load()如何处理要加载的内容中的标记的许多问题后,我看到jQuery去掉内联标记。但是,我想在我的网站中使用Kontactr作为联系页面,并且他们拥有的更好的AJAX嵌入是两个脚本标记,如下面的代码示例中所示。我如何解决jQuery.load()约束条件,使这些脚本标记在jQuery.load(file,callback())callback()函数中运行?jQuery.load()与AJAX Kontactr形式
的index.html
<html>
<head>
<!--include css, jquery, scripts -->
<script type="text/javascript">
$(document).ready(function() {
$('#main_content').load('contact.html #main_content', function(){
//what can I put here to run the Kontactr inline script code
//when contact.html is loaded?
});
});
</script>
</head>
<body>
<div id="main_content"><!--content will load here--></div>
</body>
</html>
contact.html
<div id="main_content">
<h1>Please Contact Us With The Form Below</h1>
<!-- jQuery.load will strip out these script tags
and the form will not be embedded. -->
<script type="text/javascript"> id = 1; </script>
<script type="text/javascript" src="http://kontactr.com/wp.js"></script>
</div>
我想,也许我可以把<div id="contact_form"/>
在contact.html,然后也许EVAL在脚本标记 $('#contact_form').html(//eval script tags result here);
内部的回调函数,但我不知道如何在语法上做到这一点。