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)"/>


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


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();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
xmlhttp.open("GET",window.location.pathname + "?uname=" + uname + "&pass=" + pass + "&login=" + 'login', true);
// window.location.pathname = http://www.abc.com/

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


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

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