How to use ajax to load pages and delete content

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.