


XMLHttpRequest object properties and the advantages and disadvantages of ajax
This time I will bring you the XMLHttpRequest object attributes and the advantages and disadvantages of ajax. What are the precautions for using the XMLHttpRequest object attributes and the advantages and disadvantages of ajax. The following is a practical case, let's take a look.
The XMLHttpRequest object has three important attributes: onreadystatechange state changeeventtrigger, this will be triggered every time the state changesEvent handler
readyState changes from 0 to 40 = Not initialized1 =Loading/server connection established2 =Loaded/Request received3 =Interacting/Request processing4 =Request completedstatusHTTP of the serverStatus code:
1 prefix: message. This type of status code means that the request has been accepted and needs to continue processing. 2 prefix: success. This type of status code means that the request has been successfully received, understood, and accepted by the server. (200:'OK')3 prefix: redirect. This type of status code indicates that the client needs to take further action to complete the request. (304:'Not Modified')4 prefix: Request error. This type of status code represents that an error may have occurred on the client, which is hindering the server's processing. 5, 6 Prefix: Server error. This type of status code represents an error or abnormal state in the process of processing the request by the server.Advantages of AjaxUpdating data without refreshingThe biggest advantage of AJAX is that it can update the entire file without refreshing it. Communicate with the server to maintain data on the premise of the page. This allows web applications to respond to user interactions more quickly and avoids sending unchanged information over the network, reducing user waiting time and bringing a very good user experience.
AJAX uses an asynchronous method to communicate with the server, without interrupting the user's operation, and has a faster response capability. Optimizes the communication between Browser and Server, reducing unnecessary data transmission, time and data traffic on the network.
AJAX can transfer some of the work previously burdened by the server to the client, using the client's idle capabilities to process it, reducing the burden on the server and bandwidth, saving space and bandwidth rental cost.
And reduce the burden on the server, the principle of AJAX is to "get data on demand", which can minimize the burden caused by redundant requests and responses on the server and improve site performance
AJAX is based on standardized and widely supported technology. It does not require downloading browser plug-ins or applets, but requires the customer to allow
JavaScript to be executed on the browser. 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.
Ajax separates the interface and application in the WEB (it can also be said to separate data and presentation), which is conducive to division of labor and cooperation and reduces WEB applications caused by non-technical personnel's modification of the page. Program errors, improved efficiency, and more suitable for the current
release system.
AJAX kills the history function, which is the destruction of the browser mechanism:
In the case of dynamically updating the page, the user cannot return to the previous page state, because the browser can only remember the static page in the history record . The difference between a page that has been completely read and a page that has been dynamically modified is very subtle;
Users will usually expect that clicking the back button will cancel their previous operation, but in an Ajax application, this will not be possible.
Those who have used Gmail know that the Ajax technology used under Gmail solves this problem. You can go back under Gmail'.
However, it cannot change the Ajax mechanism. It is just a relatively stupid one. But an effective way is to reproduce the changes on the page by creating or using a hidden IFRAME when the user clicks the back button to access the history. A related point is that using dynamic page updates makes it difficult for users to save a specific state to favorites. Solutions to this problem have also emerged, most of which use URL fragment identifiers (often called anchors, the part after the # in the URL) to keep track,
allows the user to return to a specified application state. (Many browsers allow JavaScript to dynamically update anchors, which allows Ajax applications to update anchors while updating the displayed content.) These solutions also solve many of the arguments about not supporting the back button
AJAX technology not only brings a good user experience to users, but also brings new security threats to IT companies. Ajax technology is like establishing a direct channel for enterprise data. This allows developers to inadvertently expose more data and server logic than before.
Ajax logic can be hidden from client-side security scanning technology, allowing hackers to create new attacks from remote servers. Ajax is also difficult to avoid some known security weaknesses, such as cross-site scripting attacks, SQL injection attacks, and Credentials-based security vulnerabilities.
Weak support for search engines. If used improperly, AJAX will increase network data traffic, thereby reducing the performance of the entire system.
AJAX is based on standardized and widely supported technology. There is no need to download browser plug-ins or small programs, but the customer needs to allow JavaScript to be executed on the browser. 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.
Some handheld devices (such as mobile phones, PDAs, etc.) do not yet support Ajax very well. For example, when we open a browser using Ajax technology on a mobile phone, website, it is currently not supported.
It is complex to write and error-prone; there are many redundant codes (it is a common problem of AJAX to include js files in layers, plus. A lot of server-side code in the past is now placed on the client); destroying the original standards of the Web.
The core of Ajax’s working principle and objects
The use of Polyfill annotations and preventing modifications in JS
The above is the detailed content of XMLHttpRequest object properties and the advantages and disadvantages of ajax. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

Ajax (Asynchronous JavaScript and XML) allows adding dynamic content without reloading the page. Using PHP and Ajax, you can dynamically load a product list: HTML creates a page with a container element, and the Ajax request adds the data to that element after loading it. JavaScript uses Ajax to send a request to the server through XMLHttpRequest to obtain product data in JSON format from the server. PHP uses MySQL to query product data from the database and encode it into JSON format. JavaScript parses the JSON data and displays it in the page container. Clicking the button triggers an Ajax request to load the product list.

Ajax is not a specific version, but a technology that uses a collection of technologies to asynchronously load and update web page content. Ajax does not have a specific version number, but there are some variations or extensions of ajax: 1. jQuery AJAX; 2. Axios; 3. Fetch API; 4. JSONP; 5. XMLHttpRequest Level 2; 6. WebSockets; 7. Server-Sent Events; 8, GraphQL, etc.

In order to improve Ajax security, there are several methods: CSRF protection: generate a token and send it to the client, add it to the server side in the request for verification. XSS protection: Use htmlspecialchars() to filter input to prevent malicious script injection. Content-Security-Policy header: Restrict the loading of malicious resources and specify the sources from which scripts and style sheets are allowed to be loaded. Validate server-side input: Validate input received from Ajax requests to prevent attackers from exploiting input vulnerabilities. Use secure Ajax libraries: Take advantage of automatic CSRF protection modules provided by libraries such as jQuery.
