This is a discussion on About XMLHttpRequest in AJAX within the AJAX Help forums, part of the Beginners AJAX category; Hi All, I am new to Ajax. Can you help me to fix this issue. I written small web application using JSP and AJAX in Tomcat. My req was that ...
|
|||||||
|
|
#1 (permalink) |
|
Junior Member
Join Date: Jun 2009
Posts: 1
Rep Power: 0 ![]() |
About XMLHttpRequest in AJAX
Hi All,
I am new to Ajax. Can you help me to fix this issue. I written small web application using JSP and AJAX in Tomcat. My req was that read folder structure from local directory or folder (For example C:\\SurroundSimulation_SVN_New1\\...) and show .html under that and when user click that .html i need open that by using IE or Iframe. Flow like: user click link (inbound) is in index.htm --> then folderlist.jsp will display with link (05 Jan 2009)and user click that link --> then fileslist.jsp will display with link (ABC.html) and user click that line --> final response i need open that .html in Iframe, problem: I able to click link is in index.htm and click event call folderlist.jsp throguht AJAX and from folderlist.jsp i try call the fileslist.jsp through AJAX again but i was not happened. For that I written for files 1.index.html 2.folderlist.jsp 3.fileslist.jsp 4.showRpt.jsp 5. stat_report.js (javascript) index.html ******* <html> <head> <title>Current Flows</title> </head> <script type="text/javascript" src="stat_report.js"></script> <body> <p> <a onclick="ajaxFunction('folderlist.jsp?flowname=UL_ COSMOS_ONSITE&direction=inbound')" href="">Inbound</a></p> </body> </html> folderlist.jsp ********* <%@ page import="java.io.*,java.util.Date" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Current Flows</title> </head> <script type="text/javascript" src="stat_report.js"></script> <body> <p> <a onclick="ajaxFunction('folderlist.jsp?flowname=UL_ COSMOS_ONSITE&direction=inbound')" href="">Inbound</a><BR><BR> <% String direction = request.getParameter("direction"); if(direction != null && direction.equals("inbound")) { String file = "C:\\SurroundSimulation_SVN_New1\\surrounding-simulation-stat-report\\WEB-INF\\flows\\"+request.getParameter("flowname")+"\\ "; File f = new File(file); String [] fileNames = f.list(); File [] fileObjects= f.listFiles(); %> <UL> <% for (int i = 0; i < fileObjects.length; i++) { if(fileObjects[i].isDirectory()) { %> <LI> <a onclick="ajaxFunction('fileslist.jsp?flowname=<%=r equest.getParameter("flowname") %>&direction=<%=request.getParameter("direction") %>&foldername=<%= fileNames[i] %>')" href=""><%= fileNames[i] %></a> <% } } %> </LI> </UL> <BR> <% } %> </p> </body> </html> fileslist.jsp ******* <%@ page import="java.io.*,java.util.Date" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Current Flows</title> </head> <script type="text/javascript" src="stat_report.js"></script> <body> <p> <a onclick="ajaxFunction('folderlist.jsp?flowname=UL_ COSMOS_ONSITE&direction=inbound')" href="">Inbound</a><BR><BR> <% String direction = request.getParameter("direction"); if(direction != null && direction.equals("inbound")) { String file = "C:\\SurroundSimulation_SVN_New1\\surrounding-simulation-stat-report\\WEB-INF\\flows\\"+request.getParameter("flowname")+"\\ "; File f = new File(file); String [] fileNames = f.list(); File [] fileObjects= f.listFiles(); %> <UL> <% for (int i = 0; i < fileObjects.length; i++) { if(fileObjects[i].isDirectory()) { %> <LI> <a onclick="ajaxFunction('fileslist.jsp?flowname=<%=r equest.getParameter("flowname") %>&direction=<%=request.getParameter("direction") %>&foldername=<%= fileNames[i] %>')" href=""><%= fileNames[i] %></a> <% String flowname1 = request.getParameter("flowname"); String direction1 = request.getParameter("direction"); String foldername1 = request.getParameter("foldername"); if(foldername1.equals(fileObjects[i].getName())) { String file1 = "C:\\SurroundSimulation_SVN_New1\\surrounding-simulation-stat-report\\WEB-INF\\flows\\"+flowname1+"\\"+foldername1+"\\"+dire ction1+"\\"; File f1 = new File(file1); String [] fileNames1 = f1.list(); File [] fileObjects1= f1.listFiles(); %> <UL> <% for (int j = 0; j < fileObjects1.length; j++) { if(!fileObjects1[j].isDirectory()) { %> <LI> <a onclick="openValidationRpt('showRpt.jsp?flowname=< %=flowname1 %>&foldername=<%=foldername1%>&direction=<%=direct ion1%>&rptname=<%=fileNames1[j] %>','_new')" href=""><%= fileNames1[j] %></a> <% } } %> </LI> </UL> <% } } } %> </LI> </UL> <BR> <% } %> </p> </body> </html> stat_report.js ********* function ajaxFunction(sURL) { var xmlhttp; if(xmlhttp == null){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }else if (window.ActiveXObject){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }else{ alert("Your browser does not support XMLHTTP!"); } } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.write(xmlhttp.responseText); } } xmlhttp.open("GET",sURL,true); xmlhttp.send(null); } Thanks, ssidiq |
|
|
|
| Sponsored Links | |
![]() |
| Bookmarks |
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| XMLHttpRequest not working? | btate | AJAX Questions | 0 | 04-15-2009 11:59 AM |
| Creating the XMLHTTPRequest | javarunner | AJAX Questions | 1 | 05-23-2008 02:11 PM |
| XMLHttpRequest - Security Bypass | prabhu | AJAX Articles | 0 | 12-23-2006 06:07 AM |
| Fixing AJAX: XMLHttpRequest Considered Harmful | Ajaxking | AJAX Articles | 0 | 12-17-2006 09:07 PM |