Home > Web Front-end > JS Tutorial > Three ways to implement ajax

Three ways to implement ajax

亚连
Release: 2018-05-10 10:33:12
Original
2509 people have browsed it

AJAX is a necessary skill for data interaction on the front end. By using AJAX, you can achieve page refresh access and bring a better experience to users.

Jquery’s ajax implementation

load method

1 Implementing the load method Only the effect of url parameter

load(url)

Three ways to implement ajax

##2 The load method has three parameters url data function

Three ways to implement ajax

The first parameter url: indicates the request path

The second parameter passes the data

The third parameter returns after receiving the servlet Related data, there are three data values ​​in it

The first is the servlet return content

The second is the status code description success

The third is the XMLHttpRequest object

$.get()

Send get request

Three ways to implement ajax

$ .post()

Send post request

Three ways to implement ajax

Writing method

$.post(url,{"name":value},function(data,status) {...})

The first parameter is: request url address

The second parameter is : The data passed

The third parameter is: callback function (data: indicates the return data; status: indicates the return status code description)

$.ajax()


Send asynchronous operation

Three ways to implement ajax


##Commonly used Parameters:

type: Set the submission method get or post

dataType: Set the format of the returned data

url: Set the request path

data: Pass parameters name=value&name2=value

success: After the request is successful, the bound callback function

has two parameters data: indicates the return data; stauts indicates the return status code description

The above are the three implementation methods of ajax and jquery that I compiled. I hope it will be helpful to everyone in the future.

Related articles:

Concepts and advantages of Ajax

jQuery Ajax verification username

PHP Example - AJAX real-time search related knowledge

The above is the detailed content of Three ways to implement ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template