【发布时间】:2017-01-19 06:30:24
【问题描述】:
Vue-资源发布请求:
this.$http.post(form.action, new FormData(form)).then(function (response) {
FetchResponse.fetch(this, response.data)
})
请求以 Content-Type:"application/json;charset=utf-8" 形式发送,但 PHP Post 无法显示任何数据。
设置标头 Vue-Resource:
request.headers.set('Content-Type', '');
但请求 Content-Type:", multipart/form-data;boundary=----WebKitFormBoundaryTsrUACAFB1wuhFOR"
查询的开头有一个逗号。
Jquery 发布请求:
$.ajax({
url : form.action,
type : 'POST',
data : new FormData(form),
success : function (reqData) {
FetchResponse.fetch(ss, reqData)
},
});
相同的查询与 jQuery 无缝协作。 jQuery Content-Type: "multipart/form-data; boundary=----WebKitFormBoundaryTsrUACAFB1wuhFOR"
【问题讨论】:
-
为什么PHP不能显示发布的数据?你得到什么错误?刚才测试的时候无法设置内容类型,不过好像没关系——Laravel 接收数据就好了,甚至是文件上传。
标签: php laravel vue.js vue-resource vue-component