iframes vs ajax [closed] iframes vs ajax [closed] ajax ajax

iframes vs ajax [closed]


For one, having an error in an included page (or ajax call) is probably better to handle with the ajax approach. With iframes you'll just get an ugly 404 or 500 error in the middle of your page. But with ajax you can detect the error and display a more user-friendly error message.

It also depends on what data you're loading into your page. If you control the html being loaded in, you can avoid or fix any display issues that may arise. If you need to load a page outside of your control, iframes would be best (or necessary).

There may also be accessibility issues involved with either approach, but I'm not familiar enough with that to determine which approach works best with screen readers, etc.


If the pages are your content, and you can control the stylesheets and everything being accessed by each one...then go with option number one. You can engineer things so you don't have to retrieve shared content more than once.

If the pages are out of your control (external sites, etc.), then load them up in iFrames. You won't have to worry about the pages rendering properly, etc.


By mixing both iframe and ajax, if your loading page (the page iframe tries to load) is not responding back immediately such that an empty white block was produced, iframe could halt other ajax requests in most browsers due to rendering.

On the other hands, iframe is more powerful, you could have stack frames especially with the transparent background, and not worrying about its width or heights, and it will appear exact like the same page without frames.