This article describes how to use ajax to load pages and delete content. The biggest benefit of ajax is that it does not jump to pages during loading and deletion. most of the current webpages are written using ajax, compared with embedded PHP code, this reduces the amount of code and speeds up page loading,
The following describes how to use ajax to delete pages and fruits written in the database fruit table as an example. it may be easy to use ajax at first, so it should be a good exercise.
This is the fruit table.
The following is the homepage code. First, create a php file main. php.
Content loading
| Fruit name |
Fruit price |
Fruit origin |
Operation |
I chose to display only the fruit name price and Origin columns in the fruit table on the page. next we will write the loading processing page and create a php file named jiazaiym. php.
Query ($ SQL); $ str = ""; foreach ($ arr as $ v) {$ str = $ str. implode ("^", $ v ). "|"; // use "|" to connect each row, so that an extra "|"} $ str = substr ($ str, 0, strlen ($ str) -1); // delete the last extra "|" in the string truncation mode echo $ str;?>
After loading the page code, you can officially write ajax, which should be written in main. php.