php ajaxturn,AJAX如何实现PUT和DELETE方法

其实这个问题挺浪费时间的

目前我在jquery里只看到了POST和GET方法

文档里写的很明白还有个$.ajax方法吧,$.post和$.get方法的文档也声明了他们只是对.ajax的封装,这是基本查文档的能力吧

$.ajax({

url: '/test',

type: 'DELETE',

data: {}

});

就在这个页面打开console运行上面这段代码,看看发出了什么请求?

真正前端却没看到有调用这两种方法的

基于Restful风格接口的前端框架不要太多,Backbone.js源码够清楚吧

你这个问题的答案,在Backbone.js源码里都有很清楚的交待:

Turn on emulateHTTP to support legacy HTTP servers. Setting this option will fake "PATCH", "PUT" and "DELETE" requests via the _method parameter and set a X-Http-Method-Override header.

Turn on Backbone.emulateHTTP in order to send PUT and DELETE requests as POST, with a _method parameter containing the true HTTP method, as well as all requests with the body as application/x-www-form-urlencoded instead of application/json with the model in a param named model. Useful when interfacing with server-side languages like PHP that make it difficult to read the body of PUT requests.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值