How does $.post () request to send data?

1, we know that the general form request is this purple

//
<form method="post" action="php.php"> 
    <input type="text" name="username" />
</form>

//
//php.php
$username = $_POST["username"]

2. The native ajax request for the xhr object looks like this:

var xmlhttp = new XMLHttpRequst();
xmlhttp.open("POST","/statics/demosource/demo_post2.php",true);

//name
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

xmlhttp.send("fname=Henry&lname=Ford");

Native ajax post request, is still a mock form, and the backend still obtains the value through the name field of the form

3, HTTP request implemented by $.post ():

//
$.post("web.php", { "username": "lofayo" }, function(data) {
    console.log(data)
})

//
//web.php
$username = $_POST["username"]

in fact, I don"t quite understand this. The most original HTTP requests are implemented through forms, and the first three methods are also implemented by simulating form requests, but this kind of release is not a simulated form, but it can still realize HTTP requests. And no matter how the front end requests, the back end obtains the sent data in a unified way

.

what is the specific principle of the HTTP request of this $.post () method? Is it really another way to request without imitating a form?

Mar.11,2021

first 2 is not a mock form, the form should be form-data , and 2 is application/x-www-form-urlencoded .
secondly, if you encapsulate the code in 2 , isn't that 3 ?
when in fact 1 2 only does one thing, which is to satisfy the http protocol, and then send it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b7de-2baa5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b7de-2baa5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?