my code-
document.getElementById("lblmsg").innerHTML=xmlhttp.responseText;
if(xmlhttp.responseText == 'Available')
{
document.getElementById("newid").value = "";
}
although response text is Available
but still it is not going in开发者_运维知识库side if condition???
Well, that should work.
Are you sure that the response text is exactly Available? Try trimming the response like this:
if(xmlhttp.responseText.trim() == 'Available')
Do you have access to firebug? Try a console.log(xmlhttp) to find out the exact value of the responseText.
After hours of searching I found this pitfall: http://www.vertstudios.com/blog/avoiding-ajax-newline-pitfall/
This solved everything without $.trim()
. Somewhere in my included files was a lonely linebreak!
精彩评论