开发者

What is considered a "best practice" for the design of a set of PHP scripts which service AJAX requests?

I am designing a website which will query a simple MySQL database using AJAX calls to PHP scripts.

I have looked into frameworks which achieve this but I'm l开发者_运维知识库ooking for a lighter weight solution and so am rolling my own. At present I have all AJAX calls hitting a single script, which then calls further functions based on the content of POSTed variables. Those functions return objects or throw exceptions, and in my main script I either return a JSON encoded version of the object or catch the exceptions and return a JSON encoded "error object".

Does this approach sound ok or not? If not, what is best practice in this scenario?


on the serverside i would reommend a restful approach.

and for the client side javascript i would recommend jQuery ($().ajax())

and it probably would't hurt to code after the principles of MVC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜