Briefly talk about the core objects of AJAX
The core object is XMLHttpRequest, which can update web pages without reloading the page. After the page is loaded, the client requests data from the server. After the page is loaded, the server receives data and sends data to the client in the background. .
Ajax is a new technology that was only born in February 2005 but is already very popular. This new technology can greatly improve the user experience of the website.
What is Ajax
Ajax is the English abbreviation of Asynchronous JavaScript and XML.
The core concept of Ajax is to use the XMLHttpRequest object to send asynchronous requests. Ajax is not a new language Or technology, it is actually a combination of several technologies in a certain way, playing their respective roles in joint collaboration.
Advantages of Ajax
1. Reduce the burden on the server. The principle of Ajax is "fetch data on demand".
2. No need to refresh the page, reducing user psychology and actual waiting time.
3. Bring better User experience.
4. Some of the work previously burdened by the server can be transferred to the client, using the idle capacity of the client to process, reducing the burden on the server, making full use of broadband resources, saving space and broadband rental costs.
5. Can call external data.
6. Based on standardized and widely supported technology, no need to download plug-ins or small programs.
7. Further promote page rendering Separate from data.
2. Introduction to XMLHttpRequest object
One of the biggest features of Ajax is that it can transmit or read and write data to the server without refreshing the page (also known as Refresh the update page), this feature mainly benefits from the XMLHTTP component XMLHttpRequest object.
Properties
onreadystatechange |
This event handler will be triggered every time the state changes, usually calling a JavaScript function | |
readyState | Requested state | |
responseText | The server's response is expressed as a string | |
responseXML | The server's response is expressed as XML, This object can be parsed into a DOM object | |
status | The HTTP status of the server | |
statusText | Corresponding text of HTTP status |
This event handler will be triggered every time the state changes, usually calling a JavaScript function
XMLHttpRequest method
Some commonly used methods of the XMLHttpRequest object
Method | Description |
abort() | Stop the current request |
getAllResponseHeaders() | Return all corresponding headers of the HTTP request as key/value pairs |
getResponseHeader("header") | Return the string value of the specified header |
open("method","url") | Create a call to the server. The method parameter can be GET, POST or PUT, etc.; the url parameter can be a relative URL or an absolute URL. This method also includes 3 optional parameters |
send(content) | Send a request to the server |
setRequestHeader("header","value") | Set the specified header to the provided value. The open() method must be called before setting any header |
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to terminate the ajax request being sent by js and jQuery
Share three kinds of analysis of ajax Pattern
Compare three implementations of Ajax and JSON parsing
The above is the detailed content of Briefly talk about the core objects 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

The Request object in PHP is an object used to handle HTTP requests sent by the client to the server. Through the Request object, we can obtain the client's request information, such as request method, request header information, request parameters, etc., so as to process and respond to the request. In PHP, you can use global variables such as $_REQUEST, $_GET, $_POST, etc. to obtain requested information, but these variables are not objects, but arrays. In order to process request information more flexibly and conveniently, you can

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:

Here's how to convert a MySQL query result array into an object: Create an empty object array. Loop through the resulting array and create a new object for each row. Use a foreach loop to assign the key-value pairs of each row to the corresponding properties of the new object. Adds a new object to the object array. Close the database connection.

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

In PHP, an array is an ordered sequence, and elements are accessed by index; an object is an entity with properties and methods, created through the new keyword. Array access is via index, object access is via properties/methods. Array values are passed and object references are passed.

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.
