FOSJsRoutingBundle无法正常工作

时间:2015-11-13 10:23:57

标签: ajax symfony

我正在尝试使用ajax和symfony从下拉列表获得结果;我按照提供的文档中提到的所有设置进行了操作。但我得到了 POST http://localhost/docCMS/web/app_dev.php/getclientaddress/13 500内部服务器错误

DefaultController.php

/**
* @Route("/getclientaddress/{id}", name="get_client_address", options={"expose"=true})
* @Template("SuntecMarcusAssignmentBundle:Default:getclientaddress.html.twig")
*/
public function getclientaddressAction($getclientaddress){
    $client = $this->get_client_details($id);

的routing.yml

fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

suntec_marcus_getclientaddress:
pattern:   /getclientaddress/{param}
defaults: { _controller: SuntecMarcusAssignmentBundle:Default:getclientaddress }
options:
    expose: true

AJAX

$(document).on('change', '#client',  function (){
    var client_id = $(this).val();
    var getTeamsUrl = Routing.generate('get_client_address',{ id: client_id });
    $.ajax({
        type    : "POST",
        url     : getTeamsUrl,
        success : function(response){
            alert(response);
            },error : function(XMLHttpRequest, textStatus, errorThrown){
            alert('Error : ' + errorThrown);
            }
    });
});

0 个答案:

没有答案