现有三个按钮,三个json格式数据,我想实现的功能是按下一个按钮,将相应的数据显示在网页上,按下另一个按钮,将对应的数据显示在网页上,同时清除之前数据,请哪位大虾指教下!!!
在线等指教!!!!!1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Examples</title>
<link href="layout.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="./excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="./jquery.js"></script>
<script language="javascript" type="text/javascript" src="./jquery.flot.js"></script>
</head>
<body >
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:300px;"></div>
<p>
<input class="fetchSeries" type="button" value="First dataset" onclick="">
<a style="display:none" href="data1.json">data</a>
</p>
<p>
<input class="fetchSeries" type="button" value="Second dataset">
<a style="display:none" href="data2.json">data</a>
</p>
<p>
<input class="fetchSeries" type="button" value="Third dataset" >
<a style="display:none" href="data3.json">data</a>
</p>
<script type="text/javascript">
$(function () {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { tickDecimals: 0, tickSize: 1 }
};
var data = [];
var placeholder = $("#placeholder");
$.plot(placeholder, data, options);
// fetch one series, adding to what we got
var alreadyFetched = {};
$("input.fetchSeries").click(function () {
var button = $(this);
var dataurl = button.siblings('a').attr('href');
function onDataReceived(series)
if (!alreadyFetched[series.label]) {
alreadyFetched[series.label] = true;
data.push(series);
}
// and plot all we got
$.plot(placeholder, data, options);
}
$.ajax({
url: dataurl,
method: 'GET',
dataType: 'json',
success: onDataReceived
});
});
});
</script>
</body>
</html>
在线等指教!!!!!1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Examples</title>
<link href="layout.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="./excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="./jquery.js"></script>
<script language="javascript" type="text/javascript" src="./jquery.flot.js"></script>
</head>
<body >
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:300px;"></div>
<p>
<input class="fetchSeries" type="button" value="First dataset" onclick="">
<a style="display:none" href="data1.json">data</a>
</p>
<p>
<input class="fetchSeries" type="button" value="Second dataset">
<a style="display:none" href="data2.json">data</a>
</p>
<p>
<input class="fetchSeries" type="button" value="Third dataset" >
<a style="display:none" href="data3.json">data</a>
</p>
<script type="text/javascript">
$(function () {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { tickDecimals: 0, tickSize: 1 }
};
var data = [];
var placeholder = $("#placeholder");
$.plot(placeholder, data, options);
// fetch one series, adding to what we got
var alreadyFetched = {};
$("input.fetchSeries").click(function () {
var button = $(this);
var dataurl = button.siblings('a').attr('href');
function onDataReceived(series)
if (!alreadyFetched[series.label]) {
alreadyFetched[series.label] = true;
data.push(series);
}
// and plot all we got
$.plot(placeholder, data, options);
}
$.ajax({
url: dataurl,
method: 'GET',
dataType: 'json',
success: onDataReceived
});
});
});
</script>
</body>
</html>
$(".fetchSeries").click(function(){
var url=$(this).siblings('a').attr('href');
$("#placeholder").html("加载中");
$.post(url,function(data){
$("#placeholder").html(data);
});});是这样吗?
var url=$(this).siblings('a').attr('href');
$("#placeholder").html("加载中");
$.post(url,function(data){
var obj=eval('('+data+')');
var html="";
for(var i=0;i<obj.length;i++){
html=html+obj[0].属性1+obj[1].属性2;//你在这里改就可以了
}
$("#placeholder").html(html);
});});