I am trying to set the value for a slider on a webpage using JQuery and AJAX to values stored in a class. Here is the striped down controller action:
public ActionResult GetSliderValues()
{
try
{
PredictiveModlePerformanceSettings settings_class = new PredictiveModlePerformanceSettings();
settings_class.max_degredation = 100;
return Json(settings_class, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
throw;
}
}
This is the JQuery:
$("#maxDegradationSlider").slider({
range: "min",
value: function getSliderSettings() {
$ajax({
url: '/PredictiveSystem/GetSliderValues',
type: "GET",
cache: false,
success: function (settings_class) {
$('#resinLifeExpectancySlider').val(settings_class.max_degredation);
}
});
},
min: 0,
max: 100,
step: .25,
slide: function (event, ui) {
$("#maxDegradation").text(ui.value + "%");
}
});
$("#maxDegradation").text($("#maxDegradationSlider").slider("value") + "%");
Finally, here is the C# class:
public class PredictiveModlePerformanceSettings
{
public double resin_life_expectancy { get; set; }
public double resin_age { get; set; }
public bool dont_replace_resin { get; set; }
public double regen_effectiveness { get; set; }
public double max_degredation { get; set; }
public double cleaning_efffectiveness { get; set; }
public double threshold_cleaning { get; set; }
public double threshold_replacement { get; set; }
public double source_predictability { get; set; }
public int number_of_iterations { get; set; }
public int std_deviation_interval { get; set; }
}
I think my mistake is in the value:
portion of the code. I don't think that is where my function should go to set the value.
This is the result I am getting: