Home > Article > Web Front-end > What is the difference between ajax and javascript
The difference between ajax and javascript: 1. JavaScript is a just-in-time compiled programming language, while Ajax is a technology used to create faster and more interactive web applications; 2. Ajax does not No browser plug-in is required, but the user is required to allow JavaScript to execute on the browser.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
The difference between ajax and javascript
Javascript introduction:
JavaScript (referred to as "JS") is a function-first A lightweight, interpreted or just-in-time compiled programming language. Although it is famous as a scripting language for developing Web pages, it is also used in many non-browser environments. JavaScript is a dynamic scripting language based on prototype programming, multi-paradigm, and supports object-oriented, imperative and declarative (such as functional programming) style.
JavaScript script language has the following characteristics:
(1) Script language. JavaScript is an interpreted scripting language. Languages such as C and C are compiled first and then executed, while JavaScript is interpreted line by line during the running of the program.
(2) Based on objects. JavaScript is an object-based scripting language that can not only create objects but also use existing objects.
(3)Simple. The JavaScript language uses weakly typed variable types and does not impose strict requirements on the data types used. It is a scripting language based on Java's basic statements and controls, and its design is simple and compact.
(4)Dynamic. JavaScript is an event-driven scripting language that can respond to user input without going through a Web server. When visiting a web page, JavaScript can directly respond to these events when the mouse is clicked, moved up or down, or moved in the window.
(5) Cross-platform. The JavaScript scripting language does not depend on the operating system and only requires browser support. Therefore, after writing a JavaScript script, it can be brought to any machine for use, provided that the browser on the machine supports the JavaScript scripting language. JavaScript has been supported by most browsers. Unlike server-side scripting languages, such as PHP and ASP, JavaScript is mainly used as a client-side scripting language to run on the user's browser and does not require server support. Therefore, in the early days, programmers preferred JavaScript to reduce the burden on the server, but at the same time it also brought about another problem, security.
As servers become more powerful, although programmers prefer scripts running on the server to ensure security, JavaScript is still popular for its cross-platform and easy-to-use advantages. At the same time, some special functions (such as AJAX) must rely on JavaScript to be supported on the client side.
[Recommended learning: javascript advanced tutorial]
Ajax introduction:
Ajax is Asynchronous Javascript And XML (Asynchronous JavaScript and XML) A new term proposed by Jesse James Garrett in 2005 to describe a 'new' approach using a collection of existing technologies, including: HTML or XHTML, CSS, JavaScript, DOM, XML, XSLT, And most importantly XMLHttpRequest. Web applications using Ajax technology can quickly present incremental updates to the user interface without the need to reload (refresh) the entire page, which allows the program to respond to user operations faster.
Ajax Features
The biggest advantage of using Ajax is that it can maintain data without updating the entire page. This allows web applications to respond more quickly to user actions and avoids sending unchanged information over the network.
Ajax does not require any browser plug-ins, but requires the user to allow JavaScript to execute on the browser. Just like DHTML applications, Ajax applications must be rigorously tested on many different browsers and platforms. As Ajax matures, some program libraries that simplify the use of Ajax have also come out. Likewise, another assistive programming technology has emerged to provide alternative functionality for users who do not support JavaScript.
The main criticism of using Ajax is that it can break the browser's back and bookmark functionality. In the case of dynamically updated pages, the user cannot go back to the previous page state because the browser can only remember static pages in the history. The possible differences between a page that has been completely read and a page that has been dynamically modified are very subtle; users often expect to click the back button to cancel their previous operation, but in an Ajax application, this is not the case. Unable to do so. However, developers have come up with various ways to solve this problem. Most of the methods before HTML5 were to create or use a hidden IFRAME to reproduce the changes on the page when the user clicks the back button to access the history. (For example, when the user clicks back in Google Maps, it searches in a hidden IFRAME and then reflects the search results onto an Ajax element to restore the application state to what it was at that time).
Regarding the problem of not being able to add status to favorites or bookmarks, one way before HTML5 was to use URL fragment identifiers (often called anchors, the part after # in the URL) to keep track of it, allowing users to return A specified application state. (Many browsers allow JavaScript to dynamically update anchors, which allows Ajax applications to update anchors while updating the displayed content.) HTML5 will later be able to directly manipulate browsing history, store web page status in the form of strings, and add web pages to web favorites. When clipping or bookmarking, the state is retained invisibly. The above two methods can also solve the problem of being unable to retreat at the same time.
When developing Ajax, network latency—that is, the interval between the user's request and the server's response—needs to be carefully considered. Not giving users a clear response, not properly pre-reading data, or improperly handling XMLHttpRequest will make users feel bored. A common solution is to use a visual component to tell the user that the system is performing background operations and reading data and content.
The above is the detailed content of What is the difference between ajax and javascript. For more information, please follow other related articles on the PHP Chinese website!