JQuery Ajax function called twice first call working, while second is not -
platform: spring i'm using ajax call same function, first blur function , click function. blur function working while click function not. changed name of function called , it's working fine.
please me find solution. want send ajax call function 'isvalidpassword' on blur , and click function.
on both click , blur have code below.
if (oldpassword != "") { $.ajax({ url: 'isvalidpassword.html?oldpassword=' + oldpassword, type: 'get', contenttype: 'application/json; charset=utf-8', success: function (data) { if (data != "valid") $("#oldpassworderror").html(data); return false; } }); }
edit: problem. i'm trying "change password" in page. first have check password entered same saved password. i'm using ajax call. if password entered not same old password have show error message in tab out(blur) , same message should shown when user clicks "save"(click) button. ajax call working on blur function , not on click.
here "isvalidpassword" function code
@requestmapping(value = "/isvalidpassword", method = requestmethod.get) public @responsebody string isvalidpassword(@requestparam("oldpassword") string oldpassword, user user, httpsession session ) throws exception { string login = (string)session.getattribute("username"); user.setlogin(login); user.setpassword(oldpassword); string message = null; // check whether old password valid , // give message in front end if (userservice.isvalidpassword(user)) { message = "valid"; } else { message = "incorrect old password"; } return message; }
to test code properly, shall prepare ajax call way:
$.ajax({ url: 'isvalidpassword.html?oldpassword=' + oldpassword, type: 'get', contenttype: 'application/json; charset=utf-8', success: function () { alert('success'); }, error: function () { alert('error'); } });
so can observe if problem on client or server side.
Comments
Post a Comment