我正在开发一个symfony应用程序,并试图使用以下代码删除一个“记住我的cookie”:
$response->headers->clearCookie($cookieName,'/');
我必须调用response->send()方法才能生效,这完全适用于一个简单的响应,但是当我尝试将它与jsonResponse一起使用时,send()函数将返回以下错误:
JSON.parse: JSON数据后意想不到的非空格字符
我的json数据没有什么问题,即使我没有指定任何数据,似乎发送函数只是不使用jsonResponse。
下面是我的jsonResponse代码:
$array = array('message'=>'your account is disabled','success'=>false);
$response = new JsonResponse($array);
$response->send(); //this triggers the error您的帮助将不胜感激!
发布于 2016-11-04 19:38:35
您可以在控制器中使用此代码。
$array = array('message'=>'your account is disabled','success'=>false);
return new JsonResponse($array);发送,在控制器中无效,您可以在控制器中使用返回。
https://stackoverflow.com/questions/40427038
复制相似问题