0

I am using the JQuery bootstrap-slider setValue and this works:

$("#sensor1slide").slider('setValue', [30, 85], false);

However, I want to update the slider value with some values returned from an AJAX call, within another function, like this:

function LoadData() {

    $.ajax({
        url: '/SensorDatas/LoadSettings',
        type: 'GET',
        contentType: 'application/json;',
        dataType: "json",
        async: true,
        processData: false,
        cache: false,
        success: function (result) {
            $("#sensor1slide").slider('setValue', [result.min, result.max], false);        
        },
        error: function (xhr, ajaxOptions, thrownError) { alert(xhr.responseText); $("#loading").val("Error"); }

    })
}

When I place the same (previously working and recognized) function in this way, I get a error from the browser console:

TypeError: $(...).slider is not a function
$("#sensor1slide").slider('setValue', [result.sensor1min, result.sensor1max], fa...

I guess the question might be a general one, rather than specific to this function, in that how do you implement a JQuery function with another function for it still be be recognized?

tomdertech
  • 497
  • 1
  • 9
  • 27
  • Try and see if [http://jsfiddle.net/lshettyl/Lcv2h42m/](http://jsfiddle.net/lshettyl/Lcv2h42m/) helps first. – lshettyl Jun 10 '15 at 10:48
  • I tried this suggestion and I get this error: `TypeError: LoadData(...) is undefined LoadData().done(function (result) {` – tomdertech Jun 10 '15 at 10:55
  • Works here -> [http://jsfiddle.net/lshettyl/Lcv2h42m/1/](http://jsfiddle.net/lshettyl/Lcv2h42m/1/). There may be other problems on your page/script. – lshettyl Jun 10 '15 at 10:58
  • Apologies I had not added the `return` proceeding the AJAX function. While .done() now fires, I still get the original `TypeError`. – tomdertech Jun 10 '15 at 11:10

0 Answers0