How to check if the call is success or faliure ?

How to check if the call is success or faliure ?

Hi,

I am using this simple code to fetch pages...i am just not able to figure out on how to check whether the call was success or faliure so I can show appropirate error if the call failed to load the page:

function getpage (pagename, divname)
{
        $(document).ready(function()
        {
                $(divname).empty();
                $(divname).text("Loading Page Content...<br />(if the page does'nt loads for a long time then there's some error!)");
                $(divname).load(pagename);
        });
}


Please help me.

Thanks.