JQuery Bootstrap-slider function within AJAX/another Function

413 views Asked by At

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?

0

There are 0 answers