Question about javascript-php app Interface

Source: Internet
Author: User
This is the client code: {code...} server code: {code...} I only know this principle. I Don't Know How To standardize it. Ask for advice! This is the client code:

$ (Document ). ready (function () {$ ("button "). click (function () {$. ajax ({url: 'server. php ', type: 'post', timeout: 30000, error: function () {alert ('request error') ;}, success: function (msg) {alert (msg) ;}}) ;}); script

Server code:


  

I only know about this principle. I Don't Know How To standardize it. Ask for advice!

Reply content:

This is the client code:

$ (Document ). ready (function () {$ ("button "). click (function () {$. ajax ({url: 'server. php ', type: 'post', timeout: 30000, error: function () {alert ('request error') ;}, success: function (msg) {alert (msg) ;}}) ;}); script

Server code:


   

I only know about this principle. I Don't Know How To standardize it. Ask for advice!

RESTful API design guide [Ruan Yifeng]

Http://www.ruanyifeng.com/blog/2014/05/restful_api.html

Currently, the most common thing is restful. Of course, it is not necessarily implemented according to this standard. In fact, the simplest function can be implemented, and the interface format can be set internally.

In actual development
1. response class response. class, which contains the processing of different request methods, requires at least three variables, $ code status code, $ message prompt, $ data processing data, a return value of json or xml
2. Singleton mode Database class db. class encapsulation, where all database operations are placed
3. An app interface document is required.

For details, refer to MOOC. There is a php app interface course on the Internet, which is comprehensive.

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.