


Detailed explanation of Ajax features and garbled code problems
The full name of ajax is asynchronous javascript and XML, which is asynchronous js and XML. It is a partial refresh, asynchronous operation. This article introduces to you the characteristics of ajax and the problem of garbled characters. Friends who are interested should take a look at it. I hope it can help you.
Before I explain, let me tell you about the linear data structure. We can think of a single linear data structure as a line segment. A line segment has a beginning and a tail. You all know that a single thread means that the head of a line segment has no front area. , there is no trailing area at the tail, and each element in the middle has two elements before and after it. When one element is missing, two elements will know and tell you at the same time. And it doesn’t even work without a single element.
The callback function passes function A as a parameter to function B, and function B executes function A. The most common uses of callback functions are the success() and error() functions we use when requesting data with ajax, as well as the first parameter in setInterval, which also uses callback functions. Callback function, callback function, the literal meaning of callback is to turn around and go back to walk that road again. So ajax turns around and walks again when the callback function success() or error is triggered, and then it is asynchronous. At the same time, ajax is asynchronous. Similar to it, there is es6's promise (asynchronous synchronous operation) .
The process of the browser is multi-process. As for why it is the same as why you call it XXX~
The second question is when the omnipotent front-end encounters ajax acquisition Everyone should be confused about why the background data is garbled.
-Maybe it’s a network speed problem, the network is too slow.
-Maybe the encoding format is not uniform, and your backend brothers have tricked you, hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
#//1.创建xmlhttpRequest对象 var xhr; try{ xhr = new XMLHttpRequest(); console.log(5555) } catch(e){ //ie浏览器低版本兼容 xhr = new ActiveXobject("Microsoft.XMLHTTP"); } finally{ console.log(1111) } // try{} catch{} finally{}在这里是处理异常的方法,用if{}else{}也ok //if(window.XMLHttpRequest){ // xhr = new XMLHttpRequest(); // }else{ //ie浏览器低版本的兼容 // xhr = new ActiveXobject("Microsoft.XMLHTTP") //} //2.建立异步连接 xhr.open("get","url/+string",true/false);//true是异步,false是同步 //xhr.open("post","url",true/false) //3.发送异步请求 xhr.send(null);//get xhr.send(string);//post //4.获取返回数据 xhr.onreadystatechange = function (){ if((xhr.readystate)==4&&(xhr.status==200)){ var data = xhr.responseText; var data = JSON.parse(data); show(data); } } function show(data){ document.getElementById("p1").innerHTML = data; }
Related recommendations:
Examples to explain Ajax asynchronous request technology
Common use of AJAX What is the syntax
AJAX principle and CORS cross-domain method
The above is the detailed content of Detailed explanation of Ajax features and garbled code problems. 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

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.

Tips for dealing with garbled Chinese file names in PHP During the development process, we often encounter the problem of garbled Chinese file names, especially when processing files uploaded by users. In PHP, how to correctly handle garbled file names is a common and important problem. This article will introduce some techniques for dealing with garbled Chinese file names and provide specific code examples to help readers better deal with this challenge. Problem description: When users upload files, the Chinese file names sometimes appear to be garbled. This is because different operating systems and browsers

Title: Methods and code examples to solve the problem of garbled characters when importing Chinese data into Oracle. When importing Chinese data into Oracle database, garbled characters often appear. This may be due to incorrect database character set settings or encoding conversion problems during the import process. . In order to solve this problem, we can take some methods to ensure that the imported Chinese data can be displayed correctly. The following are some solutions and specific code examples: 1. Check the database character set settings In the Oracle database, the character set settings are

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 deal with the problem of garbled characters in the Linux terminal. When using the Linux system, sometimes the text displayed in the terminal will be garbled. This brings inconvenience to us when using the terminal and needs to be dealt with in time. This article will introduce how to deal with some common Linux terminal garbled problems, and provide specific code examples. Problem 1: Garbled Chinese characters on the terminal. Garbled Chinese characters on the terminal are usually caused by incorrect character encoding settings on the terminal. We can solve this problem by modifying the terminal's character encoding settings. #View the current terminal

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.

Win11 is Microsoft's latest operating system, but some users may encounter the problem of displaying garbled characters when booting, which will affect the normal use of the system. This article will introduce some methods to solve this problem. Method 1: 1. Press the [Win+S] key combination, or click the [Search icon] next to the start icon on the taskbar. In the opened Windows search, enter [Control Panel] in the search box, and then click [Open]. The best matching control panel application out of the control panel window; 2. In the control panel window, switch to the [Category] view mode, and then click [Clock and Zone-Region]; 3. In the zone window, switch to the [Management] tab, and then click [Change] System Regional Settings]; 4. [Uncheck] Beta version: Use Unicode
