php - how to retrive value from jquery ui slider and store them into database? -
hi im new javascript , ajax. problem when move slider value,the value should stored database , response should value stored. have searched many questions asked here still cant figure out yet. great.
here html code
<head> <script> $(function() { $( "#slider-range-max" ).slider({ range: "max", min: 1, max: 10, value: 2, slide: function( event, ui ) { $( "#amount" ).val( ui.value ); } }); $( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) ); $.ajax({ type:"post", url:"myslider.php", data:"vote="+$( "#slider-range-max" ).slider( "value" ), success:function(response) { alert(voted); } }) }); </script> </head>
and myslider.php connection of database,
<?php require 'connection.php'; $vote=""; if (isset($_post['slider'])) { $vote=$_post['slider']; mysqli_query("insert slider (value) values ('$vote')"); } ?>
you need use change callback slider. can correct value , post jquery ajax.
$( ".selector" ).slider({ change: function( event, ui ) { //here can post data php } });
and omikron43 right. need check parameter expecting in php, because not match sending.
Comments
Post a Comment