I have just done a few experiments and read the following code:
The following content must be replied before you can see
Jquery_data.php
Copy codeThe Code is as follows: <? Php
Echo "post :";
Print_r ($ _ POST );
Echo "get :";
Print_r ($ _ GET );
?>
Jquery_test.html
Lab 1:Copy codeThe Code is as follows: $ (function ()
{
// Post method, both of which have data
$. Post ('jquery _ data. php? V1 = 1', {v2: 2}, function (data)
{
$ ('<Pre/>'). append (data). appendTo ('body ');
});
});
/*
Returned results:
Post: Array
(
[V2] => 2
)
Get: Array
(
[V1] => 1
)
*/
Lab 2:
$ (Function ()
{
// Post method. The data is behind the address, and the second parameter is the callback function.
$. Post ('jquery _ data. php? V1 = 1', function (data)
{
$ ('<Pre/>'). append (data). appendTo ('body ');
});
});
/*
The returned result. The data is in get:
Post: Array
(
)
Get: Array
(
[V1] => 1
)
*/
Lab 3:
$ (Function ()
{
// Get method, using the data parameter to pass the value
$. Get ('jquery _ data. php', {v2: 2}, function (data)
{
$ ('<Pre/>'). append (data). appendTo ('body ');
});
});
/*
The returned result. The data is in get:
Post: Array
(
)
Get: Array
(
[V2] => 2
)
*/
Tutorial 4:
$ (Function ()
{
// Get method, both of which have data
$. Get ('jquery _ data. php? V1 = 1', {v2: 2}, function (data)
{
$ ('<Pre/>'). append (data). appendTo ('body ');
});
});
/*
The returned results are merged in the get:
Post: Array
(
)
Get: Array
(
[V1] => 1
[V2] => 2
)
*/
Lab 5:
$ (Function ()
{
// Get method, both of which have data with the same variable name
$. Get ('jquery _ data. php? V2 = 1', {v2: 2}, function (data)
{
$ ('<Pre/>'). append (data). appendTo ('body ');
});
});
/*
The returned result is that the data is in get, and the data in the data parameter overwrites the data after the address:
Post: Array
(
)
Get: Array
(
[V2] => 2
)
*/
From these few simple examples, it is not difficult to see that the data after the address is always transmitted in the form of get, whether the get method or post method is used; the data in the data parameter decides the transmission mode based on the method.
Therefore, to avoid confusion, we recommend that you do not write the data behind the address, but put it in the data parameter.
Of course, if you want to use the post method and get to pass the value, you can write the data to be passed in the get method after the address, write the data to be passed in post mode in the data parameter.
In short, the method is dead, people are active, and how to use it depends on the actual situation. I once said that practice is the only criterion for testing truth. There is nothing to do with the experiment, and the knowledge is more solid.