I am facing an issue where I am receiving data from a servlet in an AJAX function. Within this function, I am attempting to compare the response.Text
with a certain String value, for example 'x'. However, the comparison is not working as expected. The code snippet in question is as follows:
function ajaxhandler()
{
tableHtml = response.Text;
if(tableHtml == 'true')
alert("Valid Move");
else
alert("Invalid Move");
}
Unfortunately, when running this code, no alerts are produced.
In my servlet, I have implemented the following logic:
void myfunction(HttpServlet request, HttpServlet response)
{
String user = (session.getAttribute("user"));
if(user == "john")
out.println("true");
else
out.println("false");
}