IFRAME and Ajax Ratio

Source: Internet
Author: User

Speaking of bigoal, I may need to introduce this product to you, but you have a lot of understanding. Let me simply put it.

Ajax:
This is a web development technology used to create interactive web applications. It mainly uses the XMLHTTPRequest object. This object was first introduced in Internet Explorer 5. It is a technology that supports asynchronous requests. In short, XMLHttpRequest enables you to use JavaScript to request and process responses to the server without blocking users.


IFRAME:
HTML tags are used to document or floating frame ).

The above statement is entirely taken from Baidu encyclopedia. However, from their descriptive descriptions, they seem completely incomparable. However, we can use IFRAME to implement Ajax-like technologies. This is simple, and we did use it before XMLHttpRequest came out. Below we use a simple example to simulate the IFRAME remote script call. This example does not actually call the server, I just want to let everyone know how to use IFRAME to implement remote script call.


Iframe.html file:

<span style="font-size:18px;">

Server.html File

<span style="font-size:18px;">

Run this code and you will see the pop-up prompt box: 'This function is called from server.html'


In this example, we fully implement remote script calls. This seems to be the same as Ajax, but what is the difference between the two.


1. What we want to talk about first is what we generally know: asynchronous communication, the biggest feature of Ajax.


1) when you use IFRAME to request server data, the progress bar in the status bar below the browser is usually moving forward like opening a new webpage. If you set a refresh alarm sound, the computer will make a click, which may be annoying to the user. If the request is frequent, the user may feel annoyed.
2) The preceding situation does not occur when Ajax is used to request server data. However, it is assumed that the return values of the server are the same, and their speed differences are the same.

2. functions:

1) IFRAME includes a whole webpage, which is usually used when layout a webpage. This will make the web page very natural and easy to manage.

Ajax is usually used when a small part of a webpage needs to be changed. It is fast and static when the webpage content is changed. IFRAME is usually not used when you need to change the words on the webpage.


2) If you want to use a non-Refresh Technology to upload a data file, you must select IFRAME. This method is frequently used by many people. IFRAME must be flexible and simple.
With Ajax, you usually need to write a bunch of declared code, which is more troublesome than commit. However, if server is required for complex operations and the return value is a very easy result, Ajax is a good choice.

3. problems between the two:
The two problems that Ajax has encountered today are:
1) Chinese garbled characters. This seems to be a problem of encoding, which can be basically solved. However, some problems still occur in some browsers with versions earlier than fuse.


2) Cross-origin post data submission, which does not seem to be implemented directly. It can only be implemented through proxy or other methods.

These two problems are basically not met by IFRAME, but the problem with IFRAME is that
1) How many IFRAME requests do you need to create at the same time ~ Otherwise, it cannot be performed at the same time.


2) The IFRAME method processes the content of the IFRAME page, and the trigger mode of successful interaction mainly depends on.
A) Regularly read the loading status of a page: This method will definitely cause a large amount of occupation of client resources.
B) IFRAME triggers the parent page event. In this way, the returned data is added, and the variables and methods on the parent page and framework page must be consistent. (The preceding example uses this method.) at this point, only the required data (XML or text) is returned during Ajax interaction ), this is one of the biggest advantages of Ajax over IFRAME.

The above is a rough comparison between the two. For a deeper understanding, you need to practice a lot in future projects.





IFRAME and Ajax Ratio

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.