What is the difference between $.post and $.ajax

WBOY
Release: 2022-02-18 16:18:31
Original
3213 people have browsed it

Difference: 1. "$.post" is a simple and easy-to-use high-level AJAX implementation, while "$.ajax" is the underlying AJAX implementation of jQuery; 2. "$.post" only handles post request functions instead of Complex "$.ajax" does not support function execution when an error occurs, otherwise "$.ajax" must be used.

What is the difference between $.post and $.ajax

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

What is the difference between $.post and $.ajax

$.ajax is the underlying AJAX implementation of jQuery, $.ajax is a general underlying package, $.ajax() requests data After that, you need to use callback functions, including beforeSend, error, dataFilter, success, complete, etc.

$.get $.post is a simple and easy-to-use high-level implementation. We use the $.get $.post method, and jQuery will automatically encapsulate and call the underlying $.ajax.

$.get only handles simple GET request functions to replace the complex $.ajax. The callback function can be called when the request is successful. Executing functions on error is not supported, otherwise $.ajax must be used.

$.post only handles post request functionality to replace the complex $.ajax . The callback function can be called when the request is successful. Executing functions on error is not supported, otherwise $.ajax must be used.

$.get("test.php", { name: "John", time: "2pm" } ) The $.get method will automatically generate queryString and submit it to the server when requesting (name=John&time=2pm ), the data submitted by the

$.post method is directly similar to form submission, and the amount of data submitted is larger than $.get.

The difference is that get and post are further encapsulation of ajax, and the effect is exactly the same as the ajax execution type of get or post.

The reason why get post is done is to facilitate development, without the need for each I have written ajax url scuess and the like every time.

get and post can solve the problems that ajax can definitely do, and ajax is more flexible.

[Related tutorial recommendations:AJAX video tutorial]

The above is the detailed content of What is the difference between $.post and $.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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!