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.