POST & GET: theIdeaofClient/ServerCommunicati

Source: Internet
Author: User
I was busy writing other articles recently. It was written a few days ago. Today I have a bit of experience and added some thoughts. on that day, steamed stuffed bun discussed with me the sending and receiving of data between the front-end and the back-end. I thought it could be like this: the first step is the frontend submission (Useformsmethodposttopost) formaction

I was busy writing other articles recently. It was written a few days ago. Today I have a bit of experience and added some thoughts. on that day, steamed stuffed bun discussed with me the sending and receiving of data between the front-end and the back-end. I thought it could be like this: the first step is to submit data at the front-end, (Use form's method = "post" to post) form action =

I was busy writing other articles recently. It was written a few days ago. Today I have a bit of experience and added some thoughts.

On that day, steamed stuffed bun discussed the sending and receiving of data between the frontend and the backend. I thought it could be like this:

The first step is the front-end submission, (Use form'smethod="post"To post)

 

Step 2: Obtain the submitted value in the background (Use PHP's$_POSTTo get)

 
 

In this process, a very silly thing happened, that is, the old man cannot get the test locally, but I think there is no problem with my writing (called the typical programmer's thinking)
Finally, I found that the reason is that I directly run the file instead of accessing the URL.

Step 3 (optional) callback at the front end (Use JQ's$.getTo callback)

getData();function getData(){$.get('get.php',{},function(response){$('body').append(response);});}

The code itself is quite common, and below are some of my thoughts
We usually focus on specific actions, such as asking me to write a form, ajax, or php, which are clear, in this process, we have implemented communication between the client and the server. however, if I was suddenly asked to write a complete communication, I could not think of it for the first time. We would always easily ignore the global connection factors in this process.
Maybe you will ask, is this important? Is it enough to write the required code?
I thought so too. The requirements are all specific. Indeed, in the code above, macro-level communication is divided into three micro-steps, but in fact, the three pieces of code are written separately, and our vision is limited to the Code itself, instead of a complete system.
In this process, we lost a very important thing, that is, the control of the global.
Once this global thinking is lost, the front-end can only be the front-end, the back-end can only be the back-end, the code can only be the code.
My high school teacher Zheng Zhi often said that we should look at the nature of phenomena.
A piece of unreliant code is as inanimate as an organ in a bottle of formalin, and its operation makes sense only when it exists in a complete system.
Programmers should not be limited by the Code itself

C2s is coded by xiaohudie. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl

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.