I want to display data from servlet which returns json. No errors on the console and also I don't have the result.
file.js
:
$("#json_disp").click(function(){
$.ajax({
url : 'Servlet',
dataType: 'json',
success : function(json) {
$("#res").html(json.user);
}
});
file.html
:
<body>
<input type="button" value="display" id="json_disp">
<div id="res"></div>
</body>
Servlet.java
JSONObject json = new JSONObject();
User u = new User();
u.setId(1);
u.setName("Jhon");
json.put("user", u);
out.println(json);
out.flush();