Search code examples
phpjqueryajaxvariablesnouislider

send value from noUIslider to php file


I try to send the value from my slider to the saveprofile.php file with query post.

Here is my fiddle: http://jsfiddle.net/uzq7yym3/

and here the code snippet for jquery post:

     $(document).ready(function(){
         var einestundeslider = document.getElementById('slider_einestunde');
        $("#saveprofilebutton").click(function(){
            $.post('saveprofile.php', 'val=' + einestunde.noUiSlider.get(), function (response) {
      alert(response);
   });
});
          });

saveprofile.php looks like this:

   $value = $_POST['val'];
   echo "I got your value! $value";

But i receive nothing :/


Solution

  • As per JS fiddle you are missing '>' in html syntax at the end of this line: <div id="slider_einestunde"></div

    So Html code should be like this:

    <form action="saveprofile.php">
    <div id="slider_einestunde"></div>
    

    Secondly you are using wrong variable name to get the value, actual value is: 'einestundeslider' but you are using 'einestunde'

    Fixed version of your JS fiddle: http://jsfiddle.net/48n4jp33/