Get the App
SLTechnology News&Howtos  ›  Development  › 

Ajax correlation and what are its advantages and disadvantages

Shulou Source: shulou.com Published: 2022-06-03 09:40:54 11月15日 Update

Ajax is relevant and what are its advantages and disadvantages. In view of this question, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

AJAX, or Asynchronous Javascript And XML, enables no refresh status update page and asynchronous submission

Advantages:

No plug-in support is required

Excellent user experience

Improve the performance of Web programs

Reduce the burden on servers and broadband

Disadvantages:

The forward and backward buttons are broken.

The support of search engines is not enough.

Lack of development and debugging tools

Synchronous and asynchronous

Synchronization: that is, you have to do one thing at a time, and wait until the previous one is done before you can do the next thing.

Async: you don't have to wait until the previous thing is done, but do more things at the same time

JQuery encapsulates AJAX in three layers.

Bottom layer: encapsulates some operations of the basic Ajax

Global method: $.ajax ()

The submitted data is submitted in data and submitted in post. The submitted data must be packaged in "{}" and submitted in the form of "key:value".

When submitting the entire form, you can use the form serialization "serialize ()" to submit the entire form

DecodeURIComponent (): de-serialized data

EncodeURIComponent (): serializes the data, and serialize () also calls this method to serialize

SerializeArray (): convert the form to json form

$.ajaxSetup (): initializes the data of $.ajax () to set the default value of the $.ajax () object

Layer 2: Ajax encapsulated with jQuery

Local method: .load (url,data,callback)

It is more suitable for asynchronous acquisition of static files.

Global method: $.get (url,data,callback,type), $.post (url,data,callback,type)

Can be obtained asynchronously with dynamic files

Layer 3: encapsulates get

Global method: $.getJSON, $.getScript

Load request

$(document) .ajaxStart (function): the method that is triggered when the request starts

$(document) .ajaxStop (function): the method that is triggered when the request ends

JSON and JSONP

When dataType is JSON, cross-domain data cannot be obtained. You need to add "? callback=" after the domain name is added to realize the cross-domain name call data. When dataType is JSONP, cross-domain data acquisition can be implemented directly.

JQXHR object

Properties and methods of jQuery jqXHR object

The answers to the questions about Ajax and its advantages and disadvantages are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Tags: Data method sequence form encapsulation global object question pros and cons domain name form file more synchronization help support solution multitasking easy easy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Shulou Tech Info macOS MariaDB