Home >Web Front-end >JS Tutorial >How jquery implements ajax technology 2: $.post()

How jquery implements ajax technology 2: $.post()

黄舟
黄舟Original
2016-12-21 15:43:111525browse

In "How jquery implements ajax technology 1: $.ajax()" we have learned how to use jQuery's $.ajax() function to achieve ajax development needs. But compared to some other functions, the implementation process and code amount of $.ajax() are still relatively complicated.
Today we will learn about jQuery’s $.post() function. Compared with the $.ajax() function, the $.post() function is simpler and more convenient, but it can only submit data parameters to the PHP file you need to access virtually through POST.
Let’s first take a look at the parameters in the $.post() function:
$.post(url,data,callback,type)
url---The URL address of the page to be loaded.
data---Key / value parameters to be sent.
callback---Callback function when loading is successful.
type---Return content format, xml, html, script, json, text, _default.
Here is a practical example:
============================================ =====================
ajax.html


$.ajax Application

$.ajax application

This is the place that needs to be displayed
< /center>

========= ================================================== ====
ajax.php


echo 'The website you want to visit is'.$_POST['web'];

?>

The above is how jquery implements ajax Technology 2: Content of $.post(), please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Statement:
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