IonDen / ion.rangeSlider

jQuery only range slider
http://ionden.com/a/plugins/ion.rangeSlider/en.html
MIT License
2.56k stars 508 forks source link

Values from two slider via ajax #593

Closed gba1904 closed 4 years ago

gba1904 commented 5 years ago

While using only one slider, submitting the values via ajax works as expected. But I need to collect the values from two slider for the my mysql-query. How to manage to read the values from both sliders?

Thank you. Any help is welcome :)

Example: $(".S1").ionRangeSlider({ type: "double", grid: true, step: 25000, min: 50000, max: 1000000, from: 0, to: 1000000, prefix: "€", prettify_separator: ".", max_postfix: "+", skin: "big",

    onFinish: function (data) {

    $.ajax({
        type: 'POST',
        url: 'phpProcess.php', 
        data: {
            min: data.from, 
            max: data.to
          /* here goes Data from S2 */
        }
    });
}

});

$(".S2").ionRangeSlider({ type: "double", grid: true, step: 10, min: 50.00, max: 200.00, from: 0, to: 200, postfix: " qm", prettify_separator: ".", max_postfix: "+", skin: "big",

    onFinish: function (data) {

    $.ajax({
        type: 'POST',
        url: 'phpProcess.php', 
        data: {
            fl1: data.from, 
            fl2: data.to
           /* here goes Data from S1 */
        }
    });
}

});
IonDen commented 5 years ago
  1. Put both sliders inside FORM
  2. Inside onFinish callback call external function
  3. This function (call it send) will serialize form data and then send it to phpProcess
gba1904 commented 5 years ago

Sorry for my late reply IonDen, your hints pointed me to the right solution and I've learned a lot about Ajax and JavaScript in the meantime ;-)