例如后台已经搞定,REST服务已经建好了,那么前台浏览器怎么使用呢?

解决方案 »

  1.   

    前端比较麻烦,因为:
    The other HTTP methods (i.e. other than GET and POST) are not available in HTML 4.1 or XHTML 1.0.也就是说实际上HTML5以前,FORM都仅支持GET和POST。
    即便你尝试自己用Ajax来做,都未必能成功。
    在jQuery的文档中说:
    The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.(最后一句话:不是所有浏览器支持其它方式)
      

  2.   

    那个REST不是毫无意义?写出来不能用?
    我看豆瓣那个,好像是REST风格的。我想用web.py这个python的web框架,来实现REST风格的架构,但是前台页面不支持,这个问题怎么解决呢?
      

  3.   

    好消息是,IE 和 Firefox 都支持你用jQuery来执行PUT和DELETE。坏消息是,Chrome的一些版本不支持jQuery执行PUT和DELETE。所以看看你的用户群吧,应该大多数情况可用的:http://stackoverflow.com/questions/165779/are-the-put-delete-head-etc-methods-available-in-most-web-browsers
      

  4.   

    可以用POST来代替PUT和DELETE, 比如你可以埋一个hidden field叫 _method, <input type="hidden" name="_method" value="PUT">. 这样,你在后台可以根据这个字段来识别.