jquery - How to return JSON data from servlet and get that from the success call back function of ajax call -


i trying return json data servlet , access data success call function of ajax call. here js code:

$(document).ready(function() {     $("#submit").on("click", function()     {         userid = $("#usernametxt").val();         seqans = $("#seqanstxt").val();         seqques = $("#seqques").val();         command = $("#_cmd").val()         $.ajax({             type : "post",             datatype : "json",             url : "/inventory/invcontroller",             data : {_cmd : command, uid : userid, ques : seqques, ans : seqans},             success : function(retval)             {                 if(true)                 {                     $("#resetpwd").show();                 }             },             error: function(error)             {                 console.log(error);             }         });     }); }); 

here serrvlet code:

boolean issuccess = loghelper.performforgotpwdvalidation(agentdetails);     printwriter out = null;     jsonobject jsonobj = new jsonobject();     try      {         jsonobj.addproperty("isvalid", issuccess);         response.setcontenttype( "application/json" );         response.setcharacterencoding("utf-8");         out = response.getwriter();         out.write(jsonobj.tostring());         out.flush();     }      catch (ioexception e)      {         e.printstacktrace();     }         {         if( null != out )         {             out.close();         }     } 

i trying return "issuccess" json data. how should return that. please let me know how return data in success call function of ajax call.

thanks in advance.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -