nectar
nectar

Reputation: 9679

how to compare xmlhttp.responsetext?

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

Upvotes: 1

Views: 8512

Answers (2)

Sven
Sven

Reputation: 21

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!

Upvotes: 2

alexn
alexn

Reputation: 58992

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.

Upvotes: 6

Related Questions