空体问题与AJAX调用

when i try to do an AJAX call to get some html text, i get a null body file. (Context is i am trying to do a hybrid application on Android and used weinre to check what i have received from the AJAX call)

The AJAX call is within the following code:

$(document).ready(function(){  
     $("#generate").click(function(){  
    $.ajax ({  
        cache: false,
        url: "htmlpage1.html", 
        success: function(html) {
        console.log(html);
        $("#quote p").append(html);
        }
    });  
});

and the htmlpage1.html is the following

<body>  
This is page1

    <p><b>And this is some text which has been bolded</b></p>
    <p>And this is the link to page 2

</body>

did some research on stackoverflow and tried by luck with the following 'magical' line to the ajax code, the problem is somehow fixed

 if(null==document.body){document.body = $('body')[0];}

what is the reason i get this issue in the first instance and how this problem is fixed by this code

if i dont use the magical code line but instead insert a dummy tag in the html_page1 file, i manage to get the html file via AJAX (i.e. null body tag is fixed. )

You could also try to find the body tag before appending it, it might give you the content you need... try playing with the selectors, I had a similar issue before.

$("#quote p").append($(html).find("body"));