getJSON没有被调用onchange

时间:2016-07-29 13:35:53

标签: javascript jquery json ajax

我有一个输入字段用于pwd和onchange我使用了getJSON。但它没有被召集。一旦authenticationChk.html被调用但在控制台中没有看到它,我在控制器中有一些sysout。

<script src="${pageContext.request.contextPath}/jquery/jquery.js"></script>
<script src="${pageContext.request.contextPath}/jquery/jquery.form.min.js"></script>
<script src="${pageContext.request.contextPath}/jquery/jquery.validate.min.js"></script>
<script src="${pageContext.request.contextPath}/js/finTransCommon.js"></script>
<script src="${pageContext.request.contextPath}/js/json2.js"></script>
<script type="text/javascript" language="JavaScript">
jQuery(document).ready(function () {
//...

    $("#pwdOverride").change(function(){
        var pwdOverride = $("#pwdOverride").val();          
        $.getJSON(
            '${pageContext.request.contextPath}/transaction/authenticationChk.html',
            {paramFilter:'PROFILE',pwdOverride:pwdOverride},
            function(data){
                alert(JSON.stringify(data));
            }
        )
        .success(function() { alert("second success"); })
        .error(function() { alert("error"); })
        .complete(function() { alert("complete"); });                   
    });

..//

控制器代码:

@ResponseBody
@RequestMapping(value = "/authenticationChk.html", method = RequestMethod.GET)
public String authenticationChk(@RequestParam("crid") String pwdOverride) throws Exception {
    try{
    userAuthenticationService.authenticateUser("Y8RRP0", pwdOverride);
    }catch (AuthenticationException e) {
        System.out.println("new Gson().toJson(false) .. exception "+new Gson().toJson(false));
        return (new Gson().toJson(false));
    }
    System.out.println("new Gson().toJson(false) ............        "+new Gson().toJson(true));
    return (new Gson().toJson(true));
}

0 个答案:

没有答案