On my nominal.jsp page, I have included header.jsp. This is my first time using Ajax for the request in header.jsp. However, when a second Ajax request is made to the nominal.jsp, I encounter a conflict issue with the Ajax request. As a result of this problem, my preferred drop-down list does not display properly. Sometimes, when the response is entered in the JavaScript, the drop-downs are displayed correctly. But if the response is not entered in the JavaScript, the drop-downs do not appear. I've tried my best to resolve the issue but have been unsuccessful. Any help would be greatly appreciated.
Thank you,
Here is the code from my header.jsp:
<script>
headerDisplay();
function headerDisplay()
{
var url ='<%=request.getContextPath()%>/summary?operation=header';
transactionRequest(url);
}
function transactionRequest(url)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
req.onreadystatechange = transactionResponse;
try
{
req.open("POST", url, true); //was get
}
catch(e)
{
alert("Problem Communicating with Server\n"+e);
}
req.send(null);
}
else if (window.ActiveXObject)
{
// IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req)
{
req.onreadystatechange = transactionResponse;
req.open("POST", url, true);
req.send();
}
}
}
function transactionResponse()
{
if (req.readyState == 4)
{
if (req.status == 200)
{
var servletVal = req.responseText;
var myObject = eval('(' + servletVal + ')');
var userId = myObject.userId;
}
}
//... more code goes here
</script>
And here is the code from my nominal.jsp:
<%@include file="/pages/common/header.jsp"%>
<script>
function displayNominal()
{
document.getElementById("ajaxLoading").style.display="block";
var url ='<%=request.getContextPath()%>'+'/nominalList';
postRequest(url);
}
function postRequest(url)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
req.onreadystatechange = nominalSelect;
try
{
req.open("POST", url, true);
}
catch (e)
{
alert("Problem Communicating with Server\n" + e);
}
req.send(null);
}
else if (window.ActiveXObject)
{
// IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req)
{
req.onreadystatechange = nominalSelect;
req.open("POST", url, true);
req.send();
}
}
}
function nominalSelect()
{
if (req.readyState == 4)
{
if (req.status == 200)
{
var servletVal = req.responseText;
var myObject = eval('(' + servletVal + ')');
var userId = myObject.userId;
if (userId == null || userId == "")
{
window.location = '/accounts1/?status=session';
}
}
}
//... more code goes here
</script>
<body class="bodystyle" onload="displayNominal()">
<% if("N".equals(roleDemoStatus)) {%>
<!-- /#demo Header -->
<div style="top: 0px; display: block;" id="header" class="fixed">
<div class="outer">
<h1 class="blog-title" style="text-align:center;margin-top:10px;"><span style="font-weight: normal; color:#777777; font-size: 30px;">accounts<font color="#5DA915">1</font>.co</span> Demo Only - <a href="https://accounts1.co/accounts1/pages/userRegistration/signup1.jsp"><font color="red">Click Here</font></a> To Use For Free Forever</h1>
</div><!-- .outer -->
<div style="display: block;" class="shadow"></div>
</div>
<!-- /#Demo Header -->
<%} %>
</body>
Once again, thank you in advance.