Switch to full style
Codes,problems ,discussions and solutions
Post a reply

Issue in ajax

Tue Sep 04, 2012 12:17 pm

The program in forum give some error to me can any one help me

The program i used is


<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<script language="javascript">
function postRequest(strURL){
var xmlHttp;
if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
ajaxloginupdate(xmlHttp.responseText);
}
}
xmlHttp.send(strURL);
}

function ajaxloginupdate(str){
if(str == "yes"){
alert("Hi , user");
}else{
alert("Login falied try again later");
}
}

function loginajax(){
var username = window.document.loginform.uname.value;
var password = window.document.loginform.pword.value;
var url = "Login.jsp?username=" + username + "&password=" +password ;
postRequest(url);
}
</script>
</head>
<body>
<center>
<div>
<form name="loginform" onsubmit="return loginajax();">

<table border="1" cellspacing="1" cellpadding="1" align ="center">

<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>UserName</td>
<td><input type="text" name="uname" value=""/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pword" value=""/></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td><input type="button" name="LoginButton" value="Login" onclick="loginajax()"></td>
</tr>
</tbody>
</table>
</form>
</div>
</center>
</body>
</html>

The issue i faced was always display "Login falied try again later"



Re: Issue in ajax

Fri Sep 07, 2012 12:31 am

it seems your server side doesn't return text "xmlHttp.responseText" equal "Yes".

Post a reply
  Related Posts  to : Issue in ajax
 Word & ASP.Net ISSUE     -  
 Datepicker issue with Internet Explorer     -  
 how to issue the command of Ctrl-C in Java     -  
 Javascript select menu validation issue     -  
 Crystal report export to excel, page header issue asp.net     -  
 solving dojox/mobile/Heading moveTo function bug issue     -  
 What is AJAX, How to start AJAX?     -  
 AJAX WITH JSP     -  
 using ajax with asp     -  
 need help in ajax     -