I'm using the "Ion.RangeSlider" library. I'm trying to load the values via JSON but can't get the slider to accept the "from" field. I can't have the value hardcoded since the user can change it.
$(function(){
'use strict'
$('#rt').ionRangeSlider({
min: 100,
max: 100000,
step: 10,
from: loaddata(), -> Doesn't get the data from the function even though it prints it to the console.
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; -> Changing the value of the slider doesn't work as well
console.log(myObj.response_time); -> Prints 2000 to the console
return myObj.response_time;
}
};
xmlhttp.open("GET", "api/settings.json", true);
xmlhttp.send();
}
My json file:
{"response_time":7120,"led":0,"device_ip":"192.168.1.1"}