AJAX 嵌套,实现甘特图显示
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <!-- - Author(s): Renault - Date: 2015-09-06 11:09:20 - Description: --> <%@include file="/nui/common.jsp" %> <head> <title>甘特图</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link href="../demo.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.7.min.js" type="text/javascript"></script> <script src="js/jquery.fn.gantt.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <script type="text/javascript"> jQuery(function () { //生成一个1-100的随机数,以后用ID 代替 var rand= parseInt(Math.random()*100); nui.ajax({ url: "com.primeton.eos.newdataset.impl.newcomponent.defaultValue.biz.ext", type: 'POST', success: function (text) { var da=nui.encode(text.data); save(da,rand); }, error: function (jqXHR,textStatus,errorThrown) { alert(jqXHR.responseText); } }); }); //保存函数,将数据以及ID传给TEST.JSP function save(data,num){ var da={da:data,id:num}; nui.ajax({ url: "test.jsp", data: da, success: function (text) { //读请求ID的对应的文件,然后显示到前台页面 var dataPath = location.href.substring(0,location.href.lastIndexOf('/')+1) + "js/da.txt"; $(".gantt").gantt({source: dataPath}); //document.write(da); },errorThrown) { alert(jqXHR.responseText); } }); } </script> </head> <body> <div class="gantt" /> </body> </html>
test.jsp <%@page pageEncoding="UTF-8" import="java.io.*"%> <%@include file="/common/common.jsp"%> <%@include file="/common/skins/skin0/component.jsp" %> <html> <!-- - Author(s): landing - Date: 2015-09-03 22:06:50 - Description: --> <head> <title>test</title> </head> <body> <% String data=request.getParameter("da"); String id=request.getParameter("id"); System.out.print(data); byte bytes[]=new byte[512]; bytes=data.getBytes(); int b=data.length(); FileOutputStream fos; try { fos = new FileOutputStream("D:EOSideeclipseworkspacedemoGantt02com.primeton.eossrcwebcontentgantt1js"+id+".txt",false); fos.write(bytes,b); fos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //response.sendRedirect("index.jsp"); %> </body> </html> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |