Home  >  Article  >  Backend Development  >  How to get thinkphp database with ajax

How to get thinkphp database with ajax

王林
王林Original
2019-10-17 10:10:092315browse

How to get thinkphp database with ajax

1. First, create a data table and write some test data in the table. I use mysql

How to get thinkphp database with ajax

2. Write an html page to perform the functions we need

How to get thinkphp database with ajax

3. Then write the js code (ajax)

How to get thinkphp database with 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

How to get thinkphp database with ajax

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

How to get thinkphp database with ajax

6. The data is processed through a loop Fill in the page (for)

How to get thinkphp database with ajax

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!

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