Loading your content...
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
$("body").html(xmlhttp.responseText);
}
};
xmlhttp.open("GET","../stats.phtml",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send();
而且它并没有找到加载的文件统计链接的任何外部文档。 phtml(javascript和css源代码),因为相对路径的路径是文档的路径,而不是加载文档的根路径。
我需要在AJAX上执行此操作(加载页面应在执行脚本时加载内容并在3秒后显示它),所以只需执行window.location ='../stats .phtml'3秒后不是一个好的解决方案。我还想保留已加载文档中的相关链接,而不是将其移至绝对路径。有什么建议么?
2011-12-20
NotGaeL