0

動的に生成されたファイルで 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);
  }
}
  }

レディ状態をチェックするということは、ファイルのロードが完了したということではないでしょうか。

ヒントをありがとう。

4

0 に答える 0