Friday, February 27, 2009

[jQuery] Re: ajax() alternative to load() function?

Yes, make sure the dataType option is set to 'html' (which it should
be by default if your response is HTML):
http://docs.jquery.com/Ajax/jQuery.ajax#options

$.ajax({
url: 'page.php',
dataType: 'html',
timeout: 5000, // 5 seconds
success: function(html) {
$("#myDiv").html(html);
}
});

On Feb 27, 7:08 am, Adam <apcau...@gmail.com> wrote:
> Hi,
>
> Is there a way to use the ajax() function and insert html into the DOM
> similar to the load() function? I need to be able to catch errors and
> use a timeout, but replicate what load() does.
>
> Thanks.

No comments: