我想在 mysql/php 中使用范围滑块进行查询以获取列表。但我不明白如何将变量从 jQuery 传递到 php 文件。我阅读了这个页面和其他页面,但仍然没有得到结果。这是我要传递的 jQuery 代码,我应该怎么做才能传递变量?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Slider - Range slider</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#slider-range1" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount1" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( "#amount1" ).val( "$" + $( "#slider-range1" ).slider( "values", 0 ) +
" - $" + $( "#slider-range1" ).slider( "values", 1 ) );
$( "#slider-range2" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount2" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( "#amount2" ).val( "$" + $( "#slider-range2" ).slider( "values", 0 ) +
" - $" + $( "#slider-range2" ).slider( "values", 1 ) );
$.ajax("file.php", {variable1:/*variable value*/, variable2:/*variable value*/, variable3:/*variable value*/, variable4:/*variable value*/}, /* insert ajax result*/);
});
</script>
</head>
<body>
<p>
<label for="amount1">Price range:</label>
<input type="text" id="amount1" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
<div id="slider-range1"></div>
<p>
<label for="amount2">Price range:</label>
<input type="text" id="amount2" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
<div id="slider-range2"></div>
</body>
</html>