AJAX 嵌套,实现甘特图显示

前端之家收集整理的这篇文章主要介绍了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:\\EOS\\ide\\eclipse\\workspace\\demoGantt02\\com.primeton.eos\\src\\webcontent\\gantt1\\js\\"+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>

猜你在找的Ajax相关文章