admin管理员组文章数量:1356221
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 inside if condition???
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 inside if condition???
2 Answers
Reset to default 6Well, 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./blog/avoiding-ajax-newline-pitfall/
This solved everything without $.trim()
. Somewhere in my included files was a lonely linebreak!
本文标签:
版权声明:本文标题:javascript - how to compare xmlhttp.responsetext? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743962245a2569241.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论