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???

Share Improve this question edited Aug 10, 2010 at 13:45 VolkerK 96.2k20 gold badges168 silver badges232 bronze badges asked Aug 10, 2010 at 13:16 nectarnectar 9,67736 gold badges82 silver badges101 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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./blog/avoiding-ajax-newline-pitfall/

This solved everything without $.trim(). Somewhere in my included files was a lonely linebreak!

本文标签: