var typer;
function zhe(){
typer = 'spline';
search();
}
function search() {
var jsonXData = [];
var jsonyD = [];
$.ajax({
url : base + '/gateBrandCount/statisticsbySpecial.html',
data : $('#form').serialize(),
success : function(e) {
var json = eval("(" + e + ")");
for (var i = 0; i < json.length; i++) {
var specialName = json[i].specialName;
var count = json[i].count;
jsonXData.push(specialName); // 赋值
jsonyD.push(count);
}
console.log(typer);
if(typer==undefined){
console.log(typer+"11111")
var op=highchart(jsonXData,jsonyD);
op.chart.type='column';
}else{
console.log(typer+"22222")
var op=highchart(jsonXData,jsonyD);
op.chart.type="'"+typer+"'";
}
console.log(op.chart.type+" ty");
chart = new Highcharts.Chart(op);
}
})
}
highchart为一个显示柱状图的函数 返回options
就是那个typer 调用zhe() ,赋值后在search()中就是undefined
求教啊