I am trying to redirect or forward a page after making a $.ajax call
$(document).ready(function(){
$('#submit').on('click', function(){
var params = "";
$('#tableResultat > tbody > tr').each(function(){
$parent = $(this);
params += $parent.find('td:eq(0)').attr('id') + "," + $parent.find('td:eq(0)').text() + "," + $parent.find('td:eq(1)').text() + "," + $parent.find('td:eq(2)').text() +','+ $parent.find('td:eq(3)').text() +"|";
});
$.ajax({
type: 'POST',
url: '/resultat',
data:{
parametres : params
}
});
});
});
On the server side, my code looks like this:
protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException
{
String action = req.getServletPath();
if(action.equals("/resultat"))
{
String params = req.getParameter("parametres");
//save these value in DB
req.getRequestDispatcher("WEB-INF/vues/resultat.jsp").forward(req, resp);
return;
}
}
I am facing an issue where clicking on my button does not redirect me to resultat.jsp. Can anyone help me with what I might be doing wrong?
Thank you for your responses