ajax应用_AJAX的应用
ajax應用
AJAX has several benefits that can be utilized inside a web application. In this article, we'll explore some advantages of AJAX and see some of its applications.
AJAX具有可在Web應用程序內部使用的多個優點。 在本文中,我們將探討AJAX的一些優勢,并了解其一些應用 。
編寫回調 (Writing Callbacks)
Recall that a simple callback function is just one function calling another one by taking the latter as a parameter. We can use AJAX to make a callback in many applications without waiting for the page to respond with the data. Now, this has an advantage when it comes to building an application that runs fast and smoothly thereby providing great user experience. The network speeds up and performance becomes better because the network utilization is considerably reduced. Similarly, if a website has a restricted bandwidth, it considerably boosts up. This is a great exploitation of the fact that many times writing AJAX requests we only need a small amount of data for our application. It doesn't make sense to have a large response time for minimal data. The response time, network load and speed should be in accordance with the kind and amount of data we're taking in.
回想一下,簡單的回調函數只是一個將另一個作為參數調用的函數。 我們可以使用AJAX在許多應用程序中進行回調,而無需等待頁面響應數據。 現在,這對于構建快速且平穩運行的應用程序具有優勢,從而提供了出色的用戶體驗。 由于網絡利用率大大降低,因此可以加快網絡速度并提高性能。 同樣,如果網站的帶寬受到限制,則可以大大提高網站的帶寬。 這是對以下事實的一種很好的利用:多次編寫AJAX請求,我們的應用程序只需要少量數據。 響應時間長,數據量少是沒有意義的。 響應時間,網絡負載和速度應與我們要接收的數據的種類和數量一致。
進行異步調用 (Making Asynchronous Calls)
The asynchronous behavior of an application is the magic behind single-page applications. These days modern applications have a single page with multiple functions that are undisturbed when the process is fetching data from a server is going on the background. These asynchronous calls can be made with Ajax to a backend, API or a server. As a user, we never have to wait for that data to come back for seeing other pages on the website or seeing some content.
應用程序的異步行為是單頁應用程序背后的魔力。 如今,現代應用程序只有一個頁面,其中包含多個功能,而這些功能在后臺從服務器獲取數據的過程中不受干擾。 可以使用Ajax對后端,API或服務器進行這些異步調用。 作為用戶,我們無需等待數據返回就可以看到網站上的其他頁面或看到某些內容。
Alright so AJAX is used to write callbacks and making async calls, but where are these benefits utilized?
好的,所以AJAX用于編寫回調和進行異步調用,但是這些好處在哪里得到利用?
1)登錄表格 (1) Login forms)
Working with AJAX in login forms is a great way to understand it's an advantage. We create a simple login form and attach an event listener to our submit event. When this event is triggered, we make an AJAX call to our database and check for valid user credentials. All of this without the slightest need to steer away from the current page or reloading the pageA popular site like Digg has a login system that works this way.
以登錄表單使用AJAX是了解它的一個好方法。 我們創建一個簡單的登錄表單,并將事件偵聽器附加到我們的Submit事件。 觸發此事件后,我們將對數據庫進行AJAX調用,并檢查有效的用戶憑據。 所有這些都完全不需要轉向當前頁面或重新加載頁面。像Digg這樣的受歡迎的網站都具有以這種方式工作的登錄系統。
2)自動完成 (2) Autocomplete)
Google was one of the first major companies to start using AJAX. When google's search engine tool came out everyone was talking about it. You must have not noticed that the autocomplete feature inside their engine was dynamic even back then, courtesy of AJAX. When typing into the Google search bar, it starts to use AJAX to get common results from the database on each keystroke. Even now you can use AJAX to add auto-complete features on your web application easily. This is also implemented in many UI Libraries which give us the autocomplete feature using an inbuilt plugin but inside it's simple AJAX callback working on the autocomplete feature.
Google是最早使用AJAX的主要公司之一。 當Google的搜索引擎工具問世時,所有人都在談論它。 您可能還沒有注意到,即使在那時,其引擎內的自動完成功能還是動態的,這要歸功于AJAX。 在Google搜索欄中鍵入內容時,它將開始使用AJAX在每次擊鍵時從數據庫中獲取常見結果。 即使現在,您也可以使用AJAX在Web應用程序上輕松添加自動完成功能。 許多UI庫中也實現了此功能,這些庫使用內置插件為我們提供了自動完成功能,但是在內部,簡單的AJAX回調在其中使用了自動完成功能。
3)動態更新內容 (3) Dynamically updating content)
It shouldn't be a surprise that popular social media platforms established their dominance on the web by showing the user's feed, comments, posts, etc dynamically without the need to refresh the page. The AJAX engine would fetch data in real-time and show it to the user. This is how the page would update content dynamically and offers a great user experience.
流行的社交媒體平臺無需刷新頁面即可動態顯示用戶的供稿,評論,帖子等,從而在網絡上占據統治地位,這不足為奇。 AJAX引擎將實時獲取數據并將其顯示給用戶。 該頁面將以這種方式動態更新內容并提供出色的用戶體驗。
4)聊天應用 (4) Chatting applications)
Long ago, back when instant messaging had just come out and had started gaining immense popularity, most online chat rooms and chat apps were using AJAX requests for the complete functioning of their chatting applications.
很久以前,當即時消息傳遞剛剛開始并開始受到極大歡迎時,大多數在線聊天室和聊天應用程序都使用AJAX請求來實現其聊天應用程序的完整功能。
5)小部件和添加 (5) Widgets and adds)
Widgets were super popular back then just as much as ads are these days. You must have noticed a lot of times adds on a website changes after some time and all of this happens while you have been on the same page for the last 15 minutes doing possibly nothing but read out some wiki information that you need. You never clicked anywhere, never reloaded the page, the network speed was fantabulous. In such a situation if the page just out of nowhere grabs some data and updates it, while you're in awe wondering wasn't there an advertisement of mind valley here before? Now there's one for Mitashi. All of this because of AJAX callbacks and asynchronous AJAX requests.
窗口小部件在當時非常流行,就像現在的廣告一樣。 您一定已經注意到,一段時間后,網站上的很多次更改都發生了,而所有這一切都是在您過去15分鐘一直在同一頁面上時發生的,除了讀出所需的一些Wiki信息外,可能什么也沒有做。 您從來沒有單擊過任何地方,也從未重新加載過頁面,網絡速度異常驚人。 在這種情況下,如果頁面無處不在獲取一些數據并對其進行更新,而您卻對此感到敬畏,那么您是否想知道這里是否曾有過廣告宣傳? 現在,三菱有一個。 所有這些都是由于AJAX回調和異步AJAX請求。
Reference: How AJAX Works: 10 Practical Uses For AJAX
參考: AJAX的工作原理:AJAX的10種實際用途
翻譯自: https://www.includehelp.com/ajax/applications.aspx
ajax應用
總結
以上是生活随笔為你收集整理的ajax应用_AJAX的应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mkdir 函数_PHP mkdir()
- 下一篇: vc++中画线时xor_C ++'xor