The example in this article describes the usage of the get method in jQuery. Share it with everyone for your reference, the details are as follows:
Parameters: url,[data],[callback],[type]
Case 1
Form code:
1 2 3 4 5 6 |
|
To be processed div code:
1 2 3 |
|
jQuery code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
PHP code:
1 2 3 4 |
|
When the user clicks send When the button is pressed, the click event is triggered and the data is processed. Mainly pass in two parameters, one is the user name and the other is the content. These two parameters are passed to the php page. After the PHP page is processed, the input data is returned, and the get method processes the returned data. Analyzing the code, we can see that this data is written into the resText div layer. The entire process page is not refreshed. The data transfer was handled very quietly.
Case 2, processing data in xml format
The form code is the same as above.
The div code to be processed is the same as above.
jQuery code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
PHP code:
1 2 3 4 5 6 7 8 9 |
|
The parameters passed by jQuery are the same, the difference lies in the way the callback function processes the data. It can be seen from the PHP code that the data is passed in in xml format.
jQuery handles xml just like it handles html. It can get the value of the attribute or the value of the node. After getting these values, it can perform certain processing and return to the page.
I hope this article will be helpful to everyone in jQuery programming.
For more articles related to analysis of get method usage in jQuery, please pay attention to the PHP Chinese website!