1

To load a html page into a div

1) HTML Embedded Object Element

2) Jquery load

3) Ajax

Which one should be used and when should be used? Because we can achieve this by using any one of these three options. But I am not clear what should be used in what situations?

Gibbs
  • 21,904
  • 13
  • 74
  • 138
  • Refer this you may get some idea http://stackoverflow.com/questions/2076642/difference-between-id-load-and-ajax – Naresh217 Oct 01 '15 at 17:02

2 Answers2

2

1) HTML Embedded Object Element

You can use embed to add rich content, like videos, images, pdfs, etc.

2) Jquery load

You can use .load() when you want html, json, xml or any other content, and an advantage of .load() is that you can select wich portion of the page you would like to load.

A difference between load and embed is that you determine when the data is loaded, if you embed an object it will be loaded when the page loads (and can also cause page load issues because of that).

3) Ajax

Is behind the scenes exactly the same as .load(), but depending on the exact situation load() might be more convenient, and ajax more flexible.

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62
0

Embedd when you are getting data from a third party, EX: youtube video, soundloud song, etc...

and load ajax if you are loading non formated html data (IE: json or xml).

Bit68
  • 1,446
  • 10
  • 25