任何想法为什么在动态生成的文件上使用 ajax 请求时返回 null 但将该文件的内容粘贴到静态文件时,请求可以在静态文件上正确执行?
//function to load more data when the user scrolls down.
$(window).scroll(
function()
{
if ($(window).scrollTop() == $(document).height() - $(window).height())
{
request = createRequest();
if (request == null)
{alert("Unable To Create Request");
}
else
{
<!-- file with xml content is generated in php -->
var url="/xmlfile.php";
<!-- everthing works when the contents of the output are pasted into this file ->
<!-- var url="/sample.xml"; -->
request.open("GET",url,true);
request.open("GET",url,true);
request.onreadystatechange = method1;
request.send(null);
}
});
function method1()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var xmldata=request.responseXML;
<!-- returns null for php file but valid object for static xml file -->
alert('xmldata :: '+xmldata);
}
}
}
由于检查了就绪状态,这不应该意味着文件已完全加载吗?
感谢您的任何提示。
大