I am encountering an issue with the "Ion.RangeSlider" library. I am attempting to dynamically load values via JSON, but I am unable to get the slider to accept the data from the "from" field. It is important that the value is not hardcoded since the user has the ability to modify it.
$(function(){
'use strict'
$('#rt').ionRangeSlider({
min: 100,
max: 100000,
step: 10,
from: loaddata(), -> The data from the function is not being accepted despite console logging.
postfix: "ms",
prefix: "Response Time: "
});
});
function loaddata(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
//document.getElementById("rt").value = myObj.response_time; -> Attempting to change slider value also fails
console.log(myObj.response_time); -> Successfully logs 2000 in the console
return myObj.response_time;
}
};
xmlhttp.open("GET", "api/settings.json", true);
xmlhttp.send();
}
The contents of my json file:
{"response_time":7120,"led":0,"device_ip":"192.168.1.1"}