我有一个按钮,这个按钮的onclick事件我正在调用一个ajax函数,该函数将jsp页面的内容包含到一个DIV中。在JSP页面上,我对数据库进行查询,并在ResultSet中获取数据,这些数据我想在同一个JSP页面上以表格和图形的形式显示,表格我可以直接在同一页面中创建,但如何将数据传递到java脚本中来绘制图形。这是我的ajax函数:
$.ajax({
url: url,
type: 'POST',
data: symbol,
success: function(data) {
//data contain content of JSP page which also contain ResultSet and also a div element in which i want to show graph
var content =data;
//this is adding content into a div element.
$('#tt').tabs('add',{
title:title,
content:content,
closable:true
});
//here i am looking to write the code for plotting graph.
var myLine = new Chart(document.getElementById("myChart").getContext("2d")).Line(lineChartData);
},
error: function(e) {
alert("error : "+e);
//called when there is an error
//console.log(e.message);
}
});发布于 2014-04-07 20:07:06
根据结果集创建Json并在jsp中对其求值。这样,您的数据就可以在jsp中使用了。
https://stackoverflow.com/questions/22911806
复制相似问题