Home Web Front-end JS Tutorial A brief discussion on Ajax and its advantages and disadvantages

A brief discussion on Ajax and its advantages and disadvantages

May 25, 2018 am 10:45 AM
ajax Advantages and Disadvantages

I have been learning about AJAX recently and checked some information about AJAX online, mainly about the technical introduction of AJAX and its advantages and disadvantages. Here, I would like to make a small summary of the information I collected. Most of the information comes from the Internet. I will only make a classification summary here. I hope it will be helpful to friends who are learning AJAX like me.

AJAX, Asynchronous Javascript And XML, can realize non-refresh status update page and asynchronous submission

Advantages:

No plug-in support required
Excellent user experience
Improve Web program performance
Reduce the burden on servers and broadband

Disadvantages:

The forward and back buttons are broken
Search The engine's support is not enough
Lack of development and debugging tools

Synchronization and asynchronous

Synchronization: that is, you must do one thing one by one and wait for the previous one to be completed. Before you can do the next thing
Asynchronous: You don’t need to wait until the previous thing is finished, you can do multiple things at the same time

JQuery has three layers of encapsulation of AJAX

The lowest layer: encapsulates some basic Ajax operations;

Global method: $.ajax()
The submitted data is in data, submitted in post mode, and the submitted data must be wrapped with "{}" , submit in the form of "key:value"
When submitting the entire form, you can use form serialization "serialize()" to submit the entire form
decodeURIComponent(): deserialize the data
encodeURIComponent() : Serialize the data, serialize() also calls this method for serialization
serializeArray(): Convert the form into json form
$.ajaxSetup(): Initialize the data of $.ajax(), used for setting Default value of $.ajax() object
Second layer: Ajax encapsulating jQuery;

Partial method: .load(url,data,callback)
More suitable for asynchronous acquisition of static files
Global methods: $.get(url,data,callback,type),$.post(url,data,callback,type)
can be obtained asynchronously with dynamic files
The third layer: encapsulated get;

Global method: $.getJSON,$.getScript

Loading request

 $(document).ajaxStart(function): Request starts When the request ends, the triggered method

When the dataType is JSON, data cannot be obtained across domains. You must add "?callback=" after adding the domain name to achieve cross-domain call data. When dataType is JSONP, cross-domain data can be obtained directly.

JQXHR Object

The properties and methods of jQuery jqXHR object

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future. Related articles:

Ajax method of reading properties resource file data

Ajax method to regularly update a certain piece of content on the page

Ajax method to get response content length

The above is the detailed content of A brief discussion on Ajax and its advantages and disadvantages. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the advantages and disadvantages of templating? What are the advantages and disadvantages of templating? May 08, 2024 pm 03:51 PM

Templating: Pros and Cons Templating is a powerful programming technique that allows you to create reusable blocks of code. It offers a range of advantages, but also some disadvantages. Pros: Code Reusability: Templating allows you to create common code that can be reused throughout your application, reducing duplication and maintenance efforts. Consistency: Templating ensures that code snippets are implemented the same way in different locations, improving code consistency and readability. Maintainability: Changes to a template are reflected simultaneously in all code that uses it, simplifying maintenance and updates. Efficiency: Templating saves time and effort because you don't have to write the same code over and over again. Flexibility: Templating allows you to create configurable blocks of code that can be easily adapted to different application needs. shortcoming

How to solve the 403 error encountered by jQuery AJAX request How to solve the 403 error encountered by jQuery AJAX request Feb 20, 2024 am 10:07 AM

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.

Must read before purchasing a system: Analysis of the advantages and disadvantages of Win11 and Win10 Must read before purchasing a system: Analysis of the advantages and disadvantages of Win11 and Win10 Mar 28, 2024 pm 01:33 PM

In today's information age, personal computers play an important role as an indispensable tool in our daily lives. As one of the core software of computers, the operating system affects our usage experience and work efficiency. In the market, Microsoft's Windows operating system has always occupied a dominant position, and now people face the choice between the latest Windows 11 and the old Windows 10. For ordinary consumers, when choosing an operating system, they do not just look at the version number, but also understand its advantages and disadvantages.

What are the advantages and disadvantages of how Java Servlets work? What are the advantages and disadvantages of how Java Servlets work? Apr 16, 2024 pm 03:18 PM

JavaServlet is a Java class used to build dynamic web pages and serves as a bridge between client and server. Working principle: receive requests, initialize Servlet, process requests, generate responses and close Servlet. Pros: Portable, scalable, secure and easy to use. Disadvantages: Overhead, coupling, and state management. Practical case: Create a simple Servlet to display the "Hello, Servlet!" message.

How to solve jQuery AJAX request 403 error How to solve jQuery AJAX request 403 error Feb 19, 2024 pm 05:55 PM

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

PHP and Ajax: Building an autocomplete suggestion engine PHP and Ajax: Building an autocomplete suggestion engine Jun 02, 2024 pm 08:39 PM

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.

Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Jun 04, 2024 pm 03:36 PM

The choice of PHP framework depends on project needs and developer skills: Laravel: rich in features and active community, but has a steep learning curve and high performance overhead. CodeIgniter: lightweight and easy to extend, but has limited functionality and less documentation. Symfony: Modular, strong community, but complex, performance issues. ZendFramework: enterprise-grade, stable and reliable, but bulky and expensive to license. Slim: micro-framework, fast, but with limited functionality and a steep learning curve.

Golang compiler summary: explore the advantages and disadvantages of various compilers Golang compiler summary: explore the advantages and disadvantages of various compilers Jan 19, 2024 am 10:44 AM

With the development of Golang, more and more compilers have been developed. When choosing a compiler, developers need to consider many factors, such as reliability, performance, ease of use, etc. This article will summarize some common Golang compilers and explore their advantages and disadvantages to help developers better choose the compiler that suits them. Go official compiler Go official compiler is Golang's default compiler and a widely recognized compiler in the Golang community. It has the following advantages: good stability, small size and compilation

See all articles