0
我的控制器:symfony的jquery的AJAX JSON錯誤
jjgp_bisa_bis_crea_mensaje: 模式:/ creamensaje 默認:{_controller:JJGPBisaBisBundle:默認:creamensaje}
我的行動功能
public function ñcreamensajeAction(){
$request = Request::createFromGlobals(); $usermail = $request->request->get('usermail'); $mensaje = $request->request->get('mensaje'); $leido = $request->request->get('leido'); $fecha = date("d-m-Y H:i:s"); $em = $this->getDoctrine()->getManager(); $mensajes = $em->getRepository('JJGPBisaBisBundle:Mensajes')->CrearMensajes($usermail, $mensaje, $fecha, $leido); $em = $this->getDoctrine()->getManager(); $em->persist($mensajes); $em->flush(); // response test $return['usermail'] = 'a'; $return['mensaje'] = "b"; $return['leido'] = "c"; return json_encode($return); }
我的jquery:
$.ajax({
type: 'POST',
url: '{{ path('jjgp_bisa_bis_crea_mensaje') }}',
dataType: 'json',
data: { // test vars only
usermail: "email",
mensaje: $txt_enviar ,
leido: "no"
},
success: function(data) {
alert(data.msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("error"); // always jump here!! that's the problem!
}
});
所有這一切似乎工作確定,我可以看到數據庫是如何長大了,工作正常,但jQuery的總是提醒我錯誤的功能,我不知道爲什麼!
我認爲它可以控制路徑,但我不知道