0
我希望能够在文档中设置变量,然后通过AJAX加载,获取变量的值。jQuery AJAX Load:从加载的文档中获取变量
loadme.htm:
<html>
<head>
<script>
var test_variable='I need this variable in destination document'
</script>
</head>
<body>
HTML content that will also be loaded and placed in the destination document.
</body>
</html>
目标文档:
$.ajax({
type: "GET",
url: "loadme.htm",
dataType: "html",
success: function(html){
alert(test_variable)
$('#destination').html(html)
}
});
上面的代码显然是行不通的。所以......我将如何获得已加载文档中建立的变量的值?
谢谢! :-)
嗯,我的帖子中没有看到任何问号。 – cheeken
为什么你需要从不同的页面获取变量?只需将该变量包含在外部js文件中 – Evan