How to compare xmlhttp.responsetext?

my code is

document.getElementById("lblmsg").innerHTML=xmlhttp.responseText; if(xmlhttp.responseText == 'Available') { document.getElementById("newid").value = ""; } 

, although the response text is Available , but still it does not enter the state <

+1
javascript ajax
Aug 10 2018-10-10
source share
2 answers

Well, that should work.

Are you sure the response text is exactly available? Try trimming the answer as follows:

 if(xmlhttp.responseText.trim() == 'Available') 

Do you have access to firebug? Try console.log (xmlhttp) to find out the exact value of responseText.

+6
Aug 10 2018-10-10
source

After hours of searching, I found this error: http://www.vertstudios.com/blog/avoiding-ajax-newline-pitfall/

It all $.trim() without $.trim() . Somewhere in my included files was a lone line!

+1
Jul 03 '12 at 11:11
source



All Articles