Hi all,
i'm at wits end here and hopefully someone can give me a fix action
Description: I am using serverside script and ajax to
create a tree based on user's selection.
Problem: 1. No tree is displayed(or errors) when
user selects a view.
Debug: 1. AJAX is setup to receive a custom id generated
by serverside script.
2. AJAX seems to be working correctly...the loading
icon is initiated and i used an alertbox to
show id's and all check good
3. i commented out the js script tags in
serverside CreateUnitChecklistTree()
to see if my serverside loop was woking. it
successfully printed out the varitems array
4. using simple text works fine too, so again
ajax is setup
Notes: it seems it must be the way serverside/clientside
code is printed. (order) it would be a great help
if someone knows how to setup to where i need
to assign the js when trying to print the tree
i used a dummy span tag to test the ajax...hence
why the repetitive nature of the case statement in
category_menu.asp (below)
category_menu.asp (Step 1)
this file simply collects a variable to dynamically
create an id(div(placeholder) tag name(note:yes, same name would work since using separate frames; however, it helps in modular code on serverside)) for the ajax function to send to the server response (the tree loop code)
ajax_menu.asp (Step 2)
this file grabs the div id and send to asp to process
server_response_tree.asp (Step 3)
this file collects the div placeholder id received from ajax_menu via querystring (get)...and also is where i am trying to loop the vartree items to populate the javascript function call- placed at the bootom...all ascociated js files are placed for the tree
i'm at wits end here and hopefully someone can give me a fix action
Description: I am using serverside script and ajax to
create a tree based on user's selection.
Problem: 1. No tree is displayed(or errors) when
user selects a view.
Debug: 1. AJAX is setup to receive a custom id generated
by serverside script.
2. AJAX seems to be working correctly...the loading
icon is initiated and i used an alertbox to
show id's and all check good
3. i commented out the js script tags in
serverside CreateUnitChecklistTree()
to see if my serverside loop was woking. it
successfully printed out the varitems array
4. using simple text works fine too, so again
ajax is setup
Notes: it seems it must be the way serverside/clientside
code is printed. (order) it would be a great help
if someone knows how to setup to where i need
to assign the js when trying to print the tree
i used a dummy span tag to test the ajax...hence
why the repetitive nature of the case statement in
category_menu.asp (below)
category_menu.asp (Step 1)
this file simply collects a variable to dynamically
create an id(div(placeholder) tag name(note:yes, same name would work since using separate frames; however, it helps in modular code on serverside)) for the ajax function to send to the server response (the tree loop code)
Code:
<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Category Menu</TITLE>
<script type="text/javascript" src="javascripts/ajax_menu.js"></script>
</head>
<body>
<script language="JavaScript" src="javascripts/tree.js"></script>
<script language="JavaScript" src="javascripts/tree_tpl.js"></script>
<%
sCategory= Request.QueryString("category")
Select Case sCategory
Case "my_profile"
Response.Write "<span onclick=""getAjaxMenuTree('" & sCategory & "');"">Test AJAX Call</span>" & vbcrlf
Response.Write "<div id=""my_profile""></div>" & vbcrlf
Case "my_discrepancy"
Response.Write "<span onclick=""getAjaxMenuTree('" & sCategory & "');"">Test AJAX Call</span>" & vbcrlf
Response.Write "<div id=""my_discrepancy""></div>" & vbcrlf
Case "unit_discrepancy"
Response.Write "<span onclick=""getAjaxMenuTree('" & sCategory & "');"">Test AJAX Call</span>" & vbcrlf
Response.Write "<div id=""unit_discrepancy""></div>" & vbcrlf
Case "unit_checklist"
Response.Write "<span onclick=""getAjaxMenuTree('" & sCategory & "');"">Test AJAX Call</span>" & vbcrlf
Response.Write "<div id=""unit_checklist""></div>" & vbcrlf
Case "my_checklist"
Response.Write "<span onclick=""getAjaxMenuTree('" & sCategory & "');"">Test AJAX Call</span>" & vbcrlf
Response.Write "<div id=""my_checklist""></div>" & vbcrlf
End Select
%>
</body>
</html>
ajax_menu.asp (Step 2)
this file grabs the div id and send to asp to process
Code:
var xmlHttp
var menu_id
var my_id
function getAjaxMenuTree(menu_id)
{
my_id = menu_id
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="server_response_tree.asp"
url=url+"?menu_id="+menu_id
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if(xmlHttp.readyState == 1)
{
document.getElementById(my_id).innerHTML = "Loading Menu...<img src='./images/loader3.gif'>";
}
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById(my_id).innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
server_response_tree.asp (Step 3)
this file collects the div placeholder id received from ajax_menu via querystring (get)...and also is where i am trying to loop the vartree items to populate the javascript function call- placed at the bootom...all ascociated js files are placed for the tree
Code:
<!-- #include file = "procedures/ConnectDatabase.asp" -->
<!-- #include file = "procedures/GetLogon.asp" -->
<!-- #include file = "procedures/CreateTreeNodes.asp" -->
<!-- #include file = "procedures/CreateTreeFramework.asp" -->
<!-- #include file = "procedures/CreateMyDiscrepancyTree.asp" -->
<!-- #include file = "procedures/CreateUnitDiscrepancyTree.asp" -->
<!-- #include file = "procedures/CreateUnitChecklistTree.asp" -->
<!-- #include file = "procedures/CreateMyChecklistTree.asp" -->
<%
Dim oConn
ConnectDatabase "USAF_SIP"
sMenuID= Request.QueryString("menu_id")
If sMenuID = "unit_checklist" Then
CreateUnitChecklistTree
Response.Write "<script language=""JavaScript"">" & vbCrlf & _
"new tree (TREE_ITEMS, TREE_TPL);" & vbCrlf & _
"</script>" & vbCrlf
End If
%>