任何想法为什么在动态生成的文件上使用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);
}
}
}
检查就绪状态时,这是否意味着文件已完全加载?
感谢您的任何提示。
达