I am using strict doctype and i want to embed a page within a page, for this i cannot use iframe as the doctype is strict , so found out 4 methods:
$.ajax()
.load()
$.getscript
<object>
tagcan any one please tell me about the pros and con of all these approaches..
Thanks
Ok, i'll attempt to answer this one.
$.ajax()
is the root method of jQuery for ajax requests. it is so detailed, you have a lot of parameters to configure it (mostly, they are left as default). this complexity gave rise to the common $.get()
and $.post()
shorthands for easy use. $.ajax()
is what you use if you want fine-grained control of the ajax request and what you want to do with it after.
.load()
is a "subfunction" of $.get()
(it uses get) but is has an implicit callback (aside from an optional callback). it instead loads the requested page, and places it in the element that precedes it as an escaped mark-up. this is good for loading pages that are already formatted to load into the target container.
.getScript()
is NOT meant to load pages. it's to retrieve scripts and execute them on the page.
<object>
tags however...
The object element’s purpose is to embed into a document a variety of different kinds of media files. Historically, it was used primarily for placing ActiveX controls onto a page, but it can also be used to embed images (.gif, .jpg, and so on), movie files and applets, video files, PDF documents, Flash, and even HTML.
although it can render HTML, it's not it's original purpose. It's meant for other media.
personally, i go for $.ajax() or $.get
to return JSON data and an HTML template, then have a template engine to build the page. this way, JSON is light on the bandwidth, and templates are cacheable.