0

Hi all...I am new to ajax and facing an uneven problem.

I am validating login form and calling the same link (with additional parameters) through xmlhttp.open(). First the form code

<div id= "login" method="GET" >  

<form action="" id="contactform">

 <input type="image" src="login-button.jpg" name="login_user" id="button" value="Login" alt="Submit button" onclick="loadXMLDoc(username.value, password.value)"/>

</form>

<span id="txtHint"></span>

</div>

Ajax code is:

<script type="text/javascript">
function loadXMLDoc(uname, pass)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",window.location.pathname + "?uname=" + uname + "&pass=" + pass + "&login=" + 'login', true);
xmlhttp.send();
}
// window.location.pathname = http://www.abc.com/
</script>

Now, I am getting a problem. After clicking login button, I am redirected to

http://www.abc.com/?username=sdwqd&password=www&login_user.x=11&login_user.y=3&login_user=Login

What is the problem....How can it use names of text fields and submit button as parameters in the url while I am not passing any of them...

Please help...

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by pclfw
0

Your function loadXMLDoc() needs to validate its inputs BEFORE trying to create and call the XML request.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.