Ajax browser problem

S

sayyedzaki

Hello friends here is my code written to create an XMLHttpRequest
object but i'm getting some error please help me resolve this problem


<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html>
<head>
<title>Admin login window </title>
<link href="views/css/transport.css" rel="stylesheet" type="text/
css" />
</head>
<script type="text/javascript" language="JavaScript" src="views/js/
pendingDocument272.js">
</script>
<script language="javascript">



//#################################################################


function ajaxFunction()
{
var httpRequest;
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
aler("Firefox, Opera 8.0+, Safari");
xmlHttp=new XMLHttpRequest();
aler("Firefox, Opera 8.0+, Safari");
}
catch (e)
{

// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
aler("Internet Explorer 6+");
}
catch (e)
{

try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
aler("Internet Explorer 5.5+");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}

/*if (window.ActiveXObject)
{
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
aler("Internet Explorer 6+");
}
else if (window.XMLHttpRequest)
{
httpRequest = new XMLHttpRequest();
aler("Firefox, Opera 8.0+, Safari");
} */
}


//#################################################################


function adminDetail(AdminLogin)
{
var value= adminLogin(AdminLogin);
if(value)
{
document.forms[0].action="ServletControllerInfo.do?
process=ProcessController&appstatus=AdminLogin&action=AdminData"
document.forms[0].submit();
return true;
}
else
return false;

}
</script>

<body onload="ajaxFunction()">
<form name="AdminLogin" method="post"
action="ServletControllerInfo.do">
<table width="900" height=250 align="center" border="0"
cellspacing="1" cellpadding="0">
<tr><td colspan=2 align="center" ></td></tr>
<tr height=210 ><td width="400"> &nbsp; </td>

<td>
<table width="500" height=120 border="0" cellspacing="1"
cellpadding="0">

<tr>
<td border="" align="left" valign="top" class="jkl detailbg "
colspan=3>Administrator Login</td><td width="500px"></td>
</tr>

<tr>
<td border="0" class="lmn2 fontname">&nbsp;Admin Name</td>
<td border="0" class="fontname">:</td>
<td border="0" class="lmn2 fontname"><input type="text"
name="adminName" class="Form_fields" value=""/></td>
</tr>

<tr>
<td border="0" class="lmn2 fontname">&nbsp;Admin Password</
td>
<td border="0" class="fontname">:</td>
<td border="0" class="lmn2 fontname"><input type="password"
name="adminPassword" class="Form_fields" value=""/></td>
</tr>

<tr>
<td class="lmn2 fontname"></td>
<td align="right" class="lmn2 fontname" colspan="2" >&nbsp;
<!--<input border="0" id="new1" name="I5" src="views/images/
login.gif" title="Click to Login" type="image" width="50" height="20"
onclick="return adminDetail();">-->
<input title="Click to Login" type="button" value="Login"
class="formbuttons" onclick="return adminDetail(AdminLogin)">
<html:reset styleClass="formbuttons" value="Reset"/>
</td>
</tr>
<tr>
<td border="" align="left" valign="top" class="jkl detailbg "
colspan=3></td><td width="500px"></td>

</tr>
</table>
</td>
</tr>

<!--</table> -->
<!--<table border=0 class="marginforMessagetable"> -->
<!-- <table width="900" height=250 align="center" border="0"
cellspacing="1" cellpadding="0">-->
<%

String StrMessage = (String)session.getAttribute("ADMINMESSAGE");
if(StrMessage != null)
{

%>
<tr><td align="center" class="message" ><%=StrMessage%></td></tr>

<%
}
session.removeAttribute("ADMINMESSAGE");
%>
</table>

</form>
</body>
 
B

Bill H

Hello friends here is my code written to create an XMLHttpRequest
object but i'm getting some error please help me resolve this problem

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html>
<head>
<title>Admin login window </title>
<link href="views/css/transport.css" rel="stylesheet" type="text/
css" />
</head>
<script type="text/javascript" language="JavaScript" src="views/js/
pendingDocument272.js">
</script>
<script language="javascript">

//#################################################################

function ajaxFunction()
{
var httpRequest;
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
aler("Firefox, Opera 8.0+, Safari");
xmlHttp=new XMLHttpRequest();
aler("Firefox, Opera 8.0+, Safari");
}
catch (e)
{

// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
aler("Internet Explorer 6+");
}
catch (e)
{

try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
aler("Internet Explorer 5.5+");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}

/*if (window.ActiveXObject)
{
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
aler("Internet Explorer 6+");
}
else if (window.XMLHttpRequest)
{
httpRequest = new XMLHttpRequest();
aler("Firefox, Opera 8.0+, Safari");
} */
}

//#################################################################

function adminDetail(AdminLogin)
{
var value= adminLogin(AdminLogin);
if(value)
{
document.forms[0].action="ServletControllerInfo.do?
process=ProcessController&appstatus=AdminLogin&action=AdminData"
document.forms[0].submit();
return true;
}
else
return false;

}
</script>

<body onload="ajaxFunction()">
<form name="AdminLogin" method="post"
action="ServletControllerInfo.do">
<table width="900" height=250 align="center" border="0"
cellspacing="1" cellpadding="0">
<tr><td colspan=2 align="center" ></td></tr>
<tr height=210 ><td width="400"> &nbsp; </td>

<td>
<table width="500" height=120 border="0" cellspacing="1"
cellpadding="0">

<tr>
<td border="" align="left" valign="top" class="jkl detailbg "
colspan=3>Administrator Login</td><td width="500px"></td>
</tr>

<tr>
<td border="0" class="lmn2 fontname">&nbsp;Admin Name</td>
<td border="0" class="fontname">:</td>
<td border="0" class="lmn2 fontname"><input type="text"
name="adminName" class="Form_fields" value=""/></td>
</tr>

<tr>
<td border="0" class="lmn2 fontname">&nbsp;Admin Password</
td>
<td border="0" class="fontname">:</td>
<td border="0" class="lmn2 fontname"><input type="password"
name="adminPassword" class="Form_fields" value=""/></td>
</tr>

<tr>
<td class="lmn2 fontname"></td>
<td align="right" class="lmn2 fontname" colspan="2" >&nbsp;
<!--<input border="0" id="new1" name="I5" src="views/images/
login.gif" title="Click to Login" type="image" width="50" height="20"
onclick="return adminDetail();">-->
<input title="Click to Login" type="button" value="Login"
class="formbuttons" onclick="return adminDetail(AdminLogin)">
<html:reset styleClass="formbuttons" value="Reset"/>
</td>
</tr>
<tr>
<td border="" align="left" valign="top" class="jkl detailbg "
colspan=3></td><td width="500px"></td>

</tr>
</table>
</td>
</tr>

<!--</table> -->
<!--<table border=0 class="marginforMessagetable"> -->
<!-- <table width="900" height=250 align="center" border="0"
cellspacing="1" cellpadding="0">-->
<%

String StrMessage = (String)session.getAttribute("ADMINMESSAGE");
if(StrMessage != null)
{

%>
<tr><td align="center" class="message" ><%=StrMessage%></td></tr>

<%
}
session.removeAttribute("ADMINMESSAGE");
%>
</table>

</form>
</body>

A quick look shows that you missed the "t" in all of your Alerts. Did
you cut / paste the original line with spelling error or is there a
Javascript command called "aler"?

Bill H
 
R

Richard Cornford

Hello friends here is my code written to create an
XMLHttpRequest object but i'm getting some error please
help me resolve this problem
<snip>

The first step if resolving an error is to read the error message
generated for the error (in IE, for example, you go into Tools->Internet
Options->Advanced and disable script debugging and enable the showing of
error messages for every script error and then re-run the script. The
error report dialog then pops up every time there is an error (and it is
always the first error reported that needs to be fixed first). The
wording of error messages is not always as obvious (or helpful) as they
could be, but they are machine generated and completely consistent in
their cause and effect relationships.

(Note: The inappropriate use of try-catch in javascript can act to
conceal and suppress errors. The javascript try-catch mechanism is
particularly ill-suited to error handling because it can only catch all
exceptions and there is virtually no standardised information to tell
you which exception has been caught. It cannot be avoided for tasks like
instantiating ActiveX objects but should otherwise be avoided in favour
of testing the viability of actions prior to taking them.)

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top