I was trying to figure out how to fix this issue - I'm not sure if it is related to my local config or on this library.
我试图弄清楚如何解决这个问题 - 我不确定它是否与我的本地配置或此库有关。
I use Angular.js to send request to REST server with Chatwork/slim-json-request as middleware. Here are the request headers:
我使用Angular.js向REST服务器发送请求,将Chatwork / slim-json-request作为中间件。以下是请求标头:
Accept:application/json, text/plain, /
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:2019
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary5q7WNrrXPm77DsQv
Host:test.localhost
Origin:http://localhost:9002
Referer:http://localhost:9002/Register
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
Now, in the function call, when I try to print out the values:
现在,在函数调用中,当我尝试打印出值时:
$app->request->getMediaType()
returns 'multipart/form-data'
$ app-> request-> getMediaType()返回'multipart / form-data'
but when I do:
但当我这样做时:
$app->request->getBody()
returns empty, this should return key-value pair sent via form submit (POST)
$ app-> request-> getBody()返回空,这应该返回通过表单提交发送的键值对(POST)
and when I do:
当我这样做时:
$app->request->post('param')
return the value passed by the request.
$ app-> request-> post('param')返回请求传递的值。
I am using Angular.js with Slim and Chatwork/slim-json-request from here.
我在这里使用带有Slim和Chatwork / slim-json-request的Angular.js。
Will appreciate any help.
将不胜感激任何帮助。
1 个解决方案
#1
0
use firefox network in development tools and check your requests sometimes it just sends OPTIONS request in Cross origin(I insist on firefox because it's network tool is much more detailed than chrome and safari) Check this out: CORS POST request to REST server
在开发工具中使用firefox网络并检查你的请求有时它只是在Cross origin发送OPTIONS请求(我坚持使用firefox,因为它的网络工具比chrome和safari更详细)检查出来:对REST服务器的CORS POST请求
#1
0
use firefox network in development tools and check your requests sometimes it just sends OPTIONS request in Cross origin(I insist on firefox because it's network tool is much more detailed than chrome and safari) Check this out: CORS POST request to REST server
在开发工具中使用firefox网络并检查你的请求有时它只是在Cross origin发送OPTIONS请求(我坚持使用firefox,因为它的网络工具比chrome和safari更详细)检查出来:对REST服务器的CORS POST请求