ajax不会从客户端向服务器端发送信息

时间:2015-03-17 15:59:51

标签: ajax

我在客户端有一个ajax:

 $("#TIPUL_ACTULUI").change(function(){
        var selectedText = $(this).find("option:selected").text();
        $.ajax({
            type:'POST',
            url: '<c:url value="/"/>searchByAct',
            data:{act:selectedText},
            dataType: 'json',
            context:this,
            success:function(data){
                $('#DREVIZ').html(data);
            },
            error:function(xmlHttpRequest, textStatus, errorThrown){
                if(xmlHttpRequest.readyState=0 || xmlHttpRequest.status == 0)
                    return;
            }
        });
    });

并在服务器端:

@RequestMapping(value="/searchByAct", method=RequestMethod.POST)
    public ModelMap acte(@RequestParam(required = false, value = "act") String act){
        ModelMap model=null;
        model.clear();
        PortalUserDetails user = (PortalUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        ArrayOfSlSordIdRegInfo arrayActe = ixService.searchActeForCUI(user.getPunctDeLucru().getCnpCuiOE(),
            String.valueOf(user.getPunctDeLucru().getIdPDL()));

        Map<String, List<SlSordIdRegInfo>> comboItemsMap4 = new HashMap<String, List<SlSordIdRegInfo>>();
        comboItemsMap4.put(Constants.CHEIE_SORD_DREVIZ, arrayActe.getSlSordIdRegInfo());

        model.addAttribute("comboItemsMap4", comboItemsMap4);

        return model;
    }   

我的问题是编译器没有到达服务器端。我做错了什么?谢谢!

2 个答案:

答案 0 :(得分:0)

当我查看代码时,唯一想到的就是将url更改为:

url: '/searchByAct',

答案 1 :(得分:0)

如果您确定网址正确,请尝试对'data'参数进行字符串化:

$.ajax({
    ...
    data: JSON.stringify({act:selectedText}),
    ...
}