Why is AJAX over iFrames?

I'm a relatively new programmer, talking to a partner who told me that before AJAX, he used an iframe to send data and modify content (obviously using JavaScript).

I realized that both methods are similar, but I did not find an article to describe their characteristics,

What are the advantages of AJAX over iframes?

EDIT I did not find any explanation of the technique, but my partner told me that he publishes the data through a hidden iframe and passes the iframe, the sound as soon as the iframe needs to be updated, but I never did it

+6
source share
5 answers
  • One of the advantages of AJAX is that it reads the status / status request. You also have access to page titles that you do not encounter Iframes.
  • Ajax can handle multiple asynchronous requests. This is a bit more complicated with iframes, since you need to create an Iframe for the request (and keep track of them all, to remove them later), instead of the same.
  • Existing libraries are full of AJAX support, and there is a large community support base.
+7
source
iframe 

is a way to show separately two (or more) web pages in one

  ajax 

is a way to combine two (or more) web pages (or new data) into one

Key benefits of Ajax that I find:

  • CSS will flow to the page called into it.
  • A way to get data and update new information to visitors without refreshing the page.

And I remember on this site the clever use of Ajax.

A'Google instant 'and suggestive search achieved with Ajax

+7
source

Only my two cents:

I agree with Chris above that I would not say that they are comparable.

In this case, I think that iFrames is easier to work with AJAX, and if you need to send a complex form to another page, but you do not need any answer - the iframe route is by far the easiest for code.

In addition, AJAX, using a metaphor, is very well versed. It will process several requests, the status of these requests and transmit data in the desired format.

+3
source

In my experience, data loaded using AJAX is easier to manipulate than data inside an iFrame. AJAX is also really good at creating a better user interface. However, I'm not sure that I necessarily put iFrames and AJAX in the same category, because AJAX is asynchronous content, and iFrame is just another page loaded from outside your site.

I could also see how iFraming creates barriers to SEO and creates a bad user experience. Honestly, if I had access to the content, I would prefer AJAX.

+2
source

I just wanted to add this because I did not see any of the answers.

The reasons for using Ajax are mostly about the controls that you get a lot. These reasons were mentioned above.

One major flaw in Ajax, however, is that it is a JS fix. JavaScript is a great language, but people have been throwing it at every problem for a while, and everything that can be optimized if they were built into browsers now runs slowly (compared to compiled languages) with JS.

iFrames is a great example of this. They represent an incredibly common use case, wanting to include some html in some other html. Unfortunately, they are not very surprising at this, often creating more headaches than anything else.

If you want to include something and not have a mess with it on your site, as well as your site to mess with it, iFrames are great. For the more common case of using some random html in some other html, Ajax is better.

And here is what I'm trying to do: it's stupid. There is no reason that there shouldn't be something like an iFrame that looks more like Ajax. But, jumping on board (like all of us) with Ajax, we now have no choice.

The biggest reason this is a problem is because JS should never have been the absolute building block of the Internet. In addition, it is used on almost every site to violate user privacy. So, if you are looking for a good reason to use iFrames, this is mine:

Feels good, no need JS. If you can improve your site with JS, and not dependent , then this is a hard-earned achievement, and the site will feel less “hacked" in general.

In any case, this is just my input.

+1
source

Source: https://habr.com/ru/post/916113/


All Articles