我正在尝试计算网站的重定向次数,例如当用户单击指向该网站的链接时。我正在通过以下方法通过请求获取网址:
/**
* @Route("/redirections")
* @Method({"GET", "POST"})
*/
public function redirectingtoAction(Request $request) {
$em = $this->getDoctrine()->getManager();
$query ="UPDATE urlproduit SET redirection = redirection + 1 WHERE url ='".$request->get('ur')."';";
$statement = $em->getConnection()->prepare($query);
$statement->execute();
return new Response($request->get('ur'));
}
这是我的树枝:
这是我的ajax调用:
$('.flux').click(function(){
ur=$(this).data('url');
console.log(url);
$.ajax({
type: "POST",
url: "../redirections",
data : { param: 'ur', value: ur },
success: function(data){
//window.location.href=data;
console.log(data);
}});});
检查_profiler时,ur始终为空,如下所示: