Hello everybody! i have a problem, i m returning a data from servlet to ajax function and in function i want to compare the response.Text with some String e.g x but it doesnot compare it. i have the following code;

function ajaxhandler()
{
tableHtml=response.Text
if(tableHtml=='true')
alert("Valid Move");
else alert("invalid move")
}

but this doesnt alert anything kindly help me

If its not alerting anything then clearly there are 2 reasons:-
1. There is an error before if(tableHtml=='true') is executed.
2. Worst case ajaxHandler() not called at all.

To debug try this:-

function ajaxhandler()
{
    alert("function called : " + response);
    tableHtml=response.Text
    if(tableHtml=='true') alert("Valid Move");
    else alert("invalid move")
}

If first alert is not popping up then #2 is the reason.
And if alert is popping up but response is undefined then #1 is the reason

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.