1. First, create a data table and write some test data in the table. I use mysql
2. Write an html page to perform the functions we need
3. Then write the js code (ajax)
4. The url that js executes jumps to is the method (getData) in the corresponding controller. Use this method to get the data from the database
5. The obtained data is processed in the return js method (because the json string is returned, so it needs to be processed) and processed into a json object
6. The data is processed through a loop Fill in the page (for)
Recommended tutorial: PHP video tutorial
The above is the detailed content of How to get thinkphp database with ajax. For more information, please follow other related articles on the PHP Chinese website!