Home > Web Front-end > JS Tutorial > Boolean Education Yan Shiba Ajax Thorough Research Video Material Sharing

Boolean Education Yan Shiba Ajax Thorough Research Video Material Sharing

巴扎黑
Release: 2017-08-30 15:41:48
Original
1191 people have browsed it

AJAX stands for "Asynchronous Javascript And XML" (Asynchronous JavaScript and XML), which refers to a web development technology for creating interactive web applications.

AJAX = Asynchronous JavaScript and XML (a subset of Standard Universal Markup Language).

AJAX is a technology for creating fast, dynamic web pages.

AJAX is a technology that can update parts of a web page without reloading the entire web page.

By exchanging a small amount of data with the server in the background, AJAX can enable asynchronous updates of web pages. This means that parts of a web page can be updated without reloading the entire page.

Traditional web pages (not using AJAX) must reload the entire web page if the content needs to be updated.

"Boolean Education Yan Shiba Ajax Thorough Research Video Tutorial" gradually introduces the related concepts, principles, implementation methods and application methods of Ajax from the shallower to the deeper, including the concept of HTTP requests, simple syntax of PHP, JSON data format, native and jQuery implementation of Ajax, cross-domain, file upload and other knowledge points.

Boolean Education Yan Shiba Ajax Thorough Research Video Material Sharing

Video playback address: //m.sbmmt.com/course/231.html

Ajax difficulty analysis:

Let us understand this problem through a simple example. Suppose you want to build a tree-structured bulletin board system (BBS), which can interact with the server according to user requests and dynamically load the information of each article, instead of loading all article information from the server at once. Each article has four related attributes: an ID that can be used as a unique identifier in the system, the name of the poster, the article content, and an array information containing the IDs of all its sub-articles. First, assume that there is a function named getArticle() that can load an article information. The parameter received by this function is the ID of the article to be loaded, through which the article information can be obtained from the server. The object it returns contains four attributes related to the article: id, name, content and children. The routine is as follows:

function ( id ) {
     var a = getArticle(id);
     document.writeln(a.name + "
" + a.content);
 }
Copy after login

However, you may notice that calling this function repeatedly with the same article ID requires repeated and unhelpful communication with the server. To solve this problem, you can consider using the function getArticleWithCache(), which is equivalent to getArticle() with caching capabilities. In this example, the data returned by getArticle() is only saved as a global variable:

var cache = {};
 function getArticleWithCache ( id ) {
     if ( !cache[id] ) {
         cache[id] = getArticle(id);
     }
     return cache[id];
 }
Copy after login

Now that the read article has been cached, let us consider the function backgroundLoad() again, which uses our The caching mechanism mentioned above loads all article information. Its purpose is to preload all its sub-articles from the background when a reader reads an article. Because the article data is structured in a tree, it is easy to write a recursive algorithm to traverse the tree and load all articles:

function backgroundLoad ( ids ) {
     for ( var i=0; i < ids.length; i++ ) {
         var a = getArticleWithCache(ids[i]);
         backgroundLoad(a.children);
     }
 }
Copy after login

backgroundLoad () function receives an array of IDs as parameters and is then called with each ID The getArticldWithCache() method defined earlier can cache the articles corresponding to each ID. Then the backgroundLoad() method is recursively called through the sub-article ID array of the loaded article, so that the entire article tree is cached.

The above is the detailed content of Boolean Education Yan Shiba Ajax Thorough Research Video Material Sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template