我有一个下拉菜单,可从我的SQL数据库中选择结果,但是在更改时,标准值会不断绘制新的标准。
尝试从函数中调用我的数据,然后根据其是否存在而执行if运算。但是,每当我在下拉列表中选择新项目时,它都会忘记我的量具对象存在吗? (g1)
$('#record-select')。on('change',function(){var self = $(this);
$.ajax({
url: 'http://devops.robertbird.com/Michael.Forest/birdnest/partials/auditSummary.php',
method: "GET",
data: { record: self.val() },
success: function (data) {
// gets rid of weird character at start of string
var cleanData = data.substring(1);
// parse incoming JSON
var results = JSON.parse(cleanData);
doGetMyData(results);
}
});
function doGetMyData(results) {
filesize = results[0].ModelFileSize;
modelhealth = results[0].ModelHealth;
unusedfams = results[0].FamUnused;
console.log(g1);
if (!g1) {
var g1 = new JustGage({
id: "filesize",
value: (parseInt(filesize)) / 1000,
min: 0,
max: 150,
hideMinMax: true,
levelColors: ["#01FF70", "#F2C80F", "#FD625E"],
labelFontColor: "#5F6B6D",
valueFontColor: "#5F6B6D",
valueFontFamily: "Helvetica",
noGradient: true
});
console.log(g1);
}
else {
console.log(g1);
g1.refresh((parseInt(filesize)) / 1000);
}
}
});
我基本上需要用新数据刷新量规,而不是重新绘制它。
任何得到极大赞赏的帮助(花了2天时间解决这个:()
自己分类
var g1 = new JustGage({id:“文件大小”,值:(parseInt(filesize))/ 1000,最小值:0,最多:150,hideMinMax:是,levelColors:[“#01FF70”,“#F2C80F”,“#FD625E”],labelFontColor:“#5F6B6D”,valueFontColor:“#5F6B6D”,valueFontFamily:“ Helvetica”,noGradient:真});
$('#record-select')。on('change',function(){var self = $(this);
$.ajax({
url: 'http://devops.robertbird.com/Michael.Forest/birdnest/partials/auditSummary.php',
method: "GET",
data: { record: self.val() },
success: function (data) {
doGetMyData(data);
}
});
function doGetMyData(results) {
// gets rid of weird character at start of string
var cleanData = results.substring(1);
// parse incoming JSON
var results = JSON.parse(cleanData);
filesize = results[0].ModelFileSize;
modelhealth = results[0].ModelHealth;
unusedfams = results[0].FamUnused;
console.log(g1);
g1.refresh((parseInt(filesize)) / 1000);
}
});