我的javascript变量声明中出现语法错误。这是我到目前为止所尝试的。第一次testArray声明后我收到错误。我尝试使用分号,但仍然会在var标记处突出显示以下行。
<script type="text/javascript">
var testArray =<%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(names) %>
var merchantname = <%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(merchant_name) %>
var successvalue = <%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(success_transcs) %>
var failedvalue = <%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(failed_transcs) %>
var servicevalue = <%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(service_transcs) %>
function gethighcharts() {
$('#chart-B').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
// categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
categories: merchantname
},
yAxis: {
min: 0,
title: {
text: 'Transaction Status'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'Service',
data: servicevalue
}, {
name: 'Failure',
data: failedvalue
}, {
name: 'Success',
data: successvalue
}]
});
}
gethighcharts();
setInterval(gethighcharts(), 60000);
});
//当我运行它时,我理解testArray中的空值,因为我没有将我的代码连接到我的服务器。但我想知道在运行代码之前是否有办法摆脱语法错误。