There is a Jquery UI double range slider on my website. But I'm getting the slider's max and min values from my database.
$.ajax({
url: "init.php",
type: "GET",
data : {"method": "price"},
async: false,
success: function(data){
var result = JSON.parse(data);
price.min = result.min;
price.max = result.max;
}
});
So i have a
price = {
max: 0,
min: 1000
};
object and i give the new values values to the parameters in the ajax success function above.
$( "#slider-range" ).slider({
range: true,
min: price.min, //these don't work
max: price.max,
values: [ price.min, price.max ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " Ft" + " - " + ui.values[ 1 ] + " Ft" );
},
change: function( event, ui){
var values ={
min: ui.values[0],
max: ui.values[1]
};
filter("price",values);
}
});
$( "#amount" ).val($( "#slider-range" ).slider( "values", 0 )
+ " Ft" + " - " + $( "#slider-range" ).slider( "values", 1 )+ " Ft");
Here is my JQuery UI double range slider object And I've got this error message in the console of the browser:
TypeError: max.toFixed is not a function[Learn More] jquery-ui.js:15006:26
There is a Jquery UI double range slider on my website. But I'm getting the slider's max and min values from my database.
$.ajax({
url: "init.php",
type: "GET",
data : {"method": "price"},
async: false,
success: function(data){
var result = JSON.parse(data);
price.min = result.min;
price.max = result.max;
}
});
So i have a
price = {
max: 0,
min: 1000
};
object and i give the new values values to the parameters in the ajax success function above.
$( "#slider-range" ).slider({
range: true,
min: price.min, //these don't work
max: price.max,
values: [ price.min, price.max ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " Ft" + " - " + ui.values[ 1 ] + " Ft" );
},
change: function( event, ui){
var values ={
min: ui.values[0],
max: ui.values[1]
};
filter("price",values);
}
});
$( "#amount" ).val($( "#slider-range" ).slider( "values", 0 )
+ " Ft" + " - " + $( "#slider-range" ).slider( "values", 1 )+ " Ft");
Here is my JQuery UI double range slider object And I've got this error message in the console of the browser:
TypeError: max.toFixed is not a function[Learn More] jquery-ui.js:15006:26
Share Improve this question asked Jul 27, 2017 at 18:30 Howard FringHoward Fring 3051 silver badge13 bronze badges 20- And how do you return those values from the ajax call ? – adeneo Commented Jul 27, 2017 at 18:32
- price.min = result.min; price.max = result.max; – Howard Fring Commented Jul 27, 2017 at 18:32
- this is in the success function – Howard Fring Commented Jul 27, 2017 at 18:33
-
1
async : false
is deprecated in modern browsers, and shouldn't be used. – adeneo Commented Jul 27, 2017 at 18:36 - 1 I converted it to number and now it works, thanks @adeneo – Howard Fring Commented Jul 27, 2017 at 19:07
1 Answer
Reset to default 12The solution:
min: Number(price.min),
max: Number(price.max),
thanks @adeneo