我尝试将我的滑块中的值发送到带有查询帖子的saveprofile.php文件。
这是我的小提琴:http://jsfiddle.net/uzq7yym3/
这里是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看起来像这样:
$value = $_POST['val'];
echo "I got your value! $value";
但我什么都没得到:/
答案 0 :(得分:2)
根据JS小提琴你缺少'&gt;'在此行末尾的html语法中:<div id="slider_einestunde"></div
所以Html代码应该是这样的:
<form action="saveprofile.php">
<div id="slider_einestunde"></div>
其次你使用错误的变量名来获取值,实际值是:'einestundeslider'但是你正在使用'einestunde'
固定版本的JS小提琴:http://jsfiddle.net/48n4jp33/