|
我写了一个下拉列表,用下拉的值传到后台,这样后台可以从数据库读取相应的数据,再发到前台,前台再根据相应的数据来画图。我是用表格的序列化来传值的(serialize())。表格如下:
<tr class="x-grid3-row " >
<td> <button id="draw" class="x-btn-text" type="button">确定</button></td>
<td><div class="x-grid3-cell-inner "><?php echo $computer_id ?></div></td>
<td ><div class="x-grid3-cell-inner " ><?php echo $property; ?></div></td>
<td><div class="x-grid3-cell-inner "><?php echo $day ?></div></td>
<td ><div class="x-grid3-cell-inner "><?php echo $hour ?></div></td>
<td ><div class="x-grid3-cell-inner "><?php echo $result ?></div></td>
<td ><div class="x-grid3-cell-inner "><?php echo $number ?></div></td>
<div style="width:450px;height:300px;text-align:center;margin:10px">
<div id="flot-placeholder1" style="width:100%;height:100%;"></div>
</tr>
然后用jsp语言来整体替换这个table,但是如果我单独使用<?php echo $number ?>的时候,取不到ajax过后的值。还是原来的默认值,请问这是怎么回事
ajax代码如下:
$(document).ready(function() {
$('#search-action').click(function(){
$.post('<?php echo site_url('computer/single')?>', $('#search-form').serialize(), function(data) {
var data1 = [];
var options = {
series: {
lines: {
show: true
},
points: {
radius: 3,
fill: true,
show: true
}
},
legend: {
noColumns: 0,
labelBoxBorderColor: "#000000",
position: "nw"
},
grid: {
hoverable: true,
borderWidth: 2,
borderColor: "#633200",
backgroundColor: { colors: ["#ffffff", "#EDF5FF"] }
},
colors: ["#FF0000", "#0022FF"]
};
for(var i=0; i<<?php echo $number ?>; i++)
{
data1[i] = [i, i];
}
var dataset = [
{ label: "Monitor", data: data1, points: { symbol: "triangle"} }
];
$('.x-grid3-row').remove();
$('.x-grid3-row',data).appendTo($('#listTable tbody'));
pageStyle();
pageClick()
$('#listTable').alternateRowColors().eventRowColors();
$.plot($("#flot-placeholder1"), dataset, options);
});
});
});
|
|