Ajax submits data to the backend php for receiving (implementation), ajax backend

Source: Internet
Author: User

Ajax submits data to the backend php for receiving (implementation), ajax backend

After reading the data online for a long time, I found that using ajax to submit data to the background is actually very simple, but many of the explanations are not clear. For Beginners, many of them are really confused and can be used directly, I want to know what is going on. In fact, Using ajax to submit data to the background is very simple.

$. Ajax ({type: "POST", url: "register. php ", data:" name = John & location = Boston ", success: function (msg) {alert (" Data Saved: "+ msg );}});

First of all, let's interpret the above Code. Of course, jQuery is needed to use ajax.

Type: "POST", which is the type of submission
Url: "register. PHP", which is the submission direction. I submitted it to register. php for processing.
Data: "name = Jhon & location = Boston". This is the data we submit. Jhon and Boston are the data we submit.
Success: function (msg)
{
Msg is the data that is returned after the submission is successful.
}

How to write the data in the background to obtain the data:

<? Php // first obtain the data $ username =$ _ POST ['name']; $ password =$ _ POST ['location']; echo $ password;?>

We can clearly see that $ _ POST ["name"]; is to get all Jhon

$ _ POST ['location'] is the obtained Boston

The data we return in the background, that is, the echo data, that is, Boston.

Hope to help you.

The above ajax data submitted to the backend for receiving (implementation method) is all the content shared by the editor. I hope to give you a reference, and I hope you can provide more support to the customer's house.

Related Article

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.