By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

string comparison is not working in this script

P: 1
Expand|Select|Wrap|Line Numbers
  1. function loadXMLDoc(theForm)
  2. {
  3.     var xmlhttp;
  4.     var str1=loginf.aid.value;
  5.     var str2=loginf.password.value;
  6.     var url="/MyBilling/Login";
  7.     url=url+"?aid="+str1;
  8.     url+="&password="+str2;
  9.  
  10.     xmlhttp=new XMLHttpRequest();
  11.  
  12.     xmlhttp.onreadystatechange=function()
  13.       {
  14.       if (xmlhttp.readyState==4 && xmlhttp.status==200)
  15.             {
  16.         success=xmlhttp.responseText;
  17.  
  18.         alert("success "+success);
  19.  
  20.         if(success=="correct")
  21.         {
  22.          window.location = "/MyBilling/web/Html/Bill_details.html";
  23.         }
  24.         else 
  25.         {
  26.          window.location = "/MyBilling/web/Html/Login_Page.html";
  27.         }
  28.            } 
  29.      }
  30.  
  31. xmlhttp.open("GET",url,true);
  32. xmlhttp.send();
  33. }
Nov 18 '11 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
maybe responseText contains newlines? try alert(success.length)
Nov 18 '11 #2

omerbutt
100+
P: 638
hi,
are you getting any error codes i Ie or FF , do you mind passing null to the send function always when using GET method in AJAX calls,
try replacing the
Expand|Select|Wrap|Line Numbers
  1. alert("success "+success);
  2.  
with this one
Expand|Select|Wrap|Line Numbers
  1. alert("|"+success+"|");
  2.  
and try to notice if ther is any extra space between the two pipe signs and the string
regards
Omer Aslam
Nov 27 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.