jQuery Ajax
<script> $("#userName").blur(function(){ $.post("UserNameTest","userName="+$("#userName").val(),function(response){ $("#msg").html(response); }); }) </script> <script> var obtn=document.getElementById("btn"); obtn.onclick=function(){ var xhr=new XMLHttpRequest(); xhr.open("get","PersonServlet","true"); xhr.send(); xhr.onreadystatechange=function(){ if(xhr.readyState==4 && xhr.status==200){ var obj=JSON.parse(xhr.responseText); alert(obj.id); } } } </script> <script> $(function(){ $("#btn").click(function(){ $.ajax({ type:"GET", url:"TestJson", dataType:"json", success:function(response){ for(var i=0;i<response.length;i++){ $("<tr>" +"<td>" +response[i].name+"</td>" +"<td>"+response[i].age+"</td>" +"</tr>" ).appendTo("#tab"); } } }); }); }) </script>