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)
##2 The load method has three parameters url data function
The first parameter url: indicates the request pathThe second parameter passes the dataThe third parameter returns after receiving the servlet Related data, there are three data values in itThe first is the servlet return contentThe second is the status code description successThe third is the XMLHttpRequest object$.get()
Send get request
$ .post()
Send post request
Writing method $.post(url,{"name":value},function(data,status) {...})The first parameter is: request url addressThe 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
##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!