js从后台无法取值问题
前台代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 |
<script type= "text/javascript" > $( function
() { var
chart; $(document).ready( function
() { chart = new
Highcharts.Chart({ chart: { renderTo: ‘container‘ , type: ‘line‘ , marginRight: 130, marginBottom: 25 }, title: { text: ‘新增用户趋势图‘ , x: -20 //center }, subtitle: { text: ‘Source: tourol.cn‘ , x: -20 }, xAxis: { categories: <font color= "#ff0000" ><%= json_dates %></font> }, yAxis: { title: { text: ‘人数‘ }, plotLines: [{ value: 0, width: 1, color: ‘#808080‘ }] }, tooltip: { formatter: function
() { return
‘<b>‘ + this .x + ‘</b><br/>‘
+ ‘新增加人数 ‘
+ this .y; } }, legend: { layout: ‘vertical‘ , align: ‘right‘ , verticalAlign: ‘top‘ , x: -10, y: 100, borderWidth: 0 }, series: [{ name: ‘新增人数‘ , data: <font color= "#ff0000" ><%= json_addusers %></font> }] }); }); }); $( function
() { $( ".index_tap_item>a" ).click( function
() { $( ".nav-stacked>li" ).each( function
() { $( this ).removeClass( ‘active‘ ); $( "#liuserstatics" ).addClass( ‘active‘ ); }); $( ".tab-pane" ).each( function
() { $( this ).removeClass( ‘active‘ ); $( "#userstatics" ).addClass( ‘active‘ ); }); }); }); </script> |
后台代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 |
public partial class
statics_Default : System.Web.UI.Page { public string json_addusers = string.Empty; public string json_dates = string.Empty; protected
void Page_Load(object sender, EventArgs e) { getData(); } private
void getData() { System.Data.DataTable datas = DBUtility.DBExecuteUtil.querySqlTable( " SELECT COUNT(*) addusers,CONVERT(varchar(100), [RegistDate], 23) dates FROM [FenxCloudZj].[dbo].[tourol_B2CUser] group by CONVERT(varchar(100), [RegistDate], 23)" ); string json1 = "[" ; string json2 = "[" ; for
(int i = (datas.Rows.Count > 10 ? 10 : datas.Rows.Count); i > 0; i--) { json1 += datas.Rows[i][ "addusers" ] + "," ; json2 += "\""
+ datas.Rows[i][ "dates" ] + "\"," ; } json1 = json1.TrimEnd( ‘,‘ ); json1 += "]" ; json_addusers = json1; json2 = json2.TrimEnd( ‘,‘ ); json2 += "]" ; json_dates = json2; } } |
不能直接使用json_addusers在查询数据库后取值,要用json1来做变量,暂时没搞清楚为什么
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。