My html page has
<div id="dialog" title="Items">
<div id="username">
<h4>Welcome <i><%=(String) session.getAttribute("username")%></i></h4>
</div>
<div id="disconnect">
<button>LogOut</button>
</div>
$(“#disconnect”).click(function(){
$.ajax({
type: "POST",
url: "XXXservlet",
success: function(data) {
window.location.replace("index,html");}
}):
Now upon click on the log out button I want to call disconnect function in my servlet.Merely redirecting to a new page wont help.I want it the user to log out of application..How do I achieve with jquery??
Note:I am using doPost in servlet
Sorry if it is a simple question.I am begineer to programming
Thanks……..
You can take help of DWR to accomplish this , on click execute servlet’s method using javascript (ajax)
You can use pure jQuery and make ajax call (GET) to some servlet which will do it for you