<?php
require '../common/pdo_connect.php';
try{
$stmt = $db->query("SELECT date FROM disabledate");
$db_ddates = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$js_ddates = "";
foreach ($db_ddates as $row => $record) {
$js_ddates .= '"' . $record['date'] . '",';
}
}
catch(\PDOException $e) {
echo $e->getMessage();
}
?>
<label>Pick a date
<input
id="drop1"
class="datepicker"
name="drop1"
type="text"
value=""
data-value="">
</label>
<div id="container"></div>
<script src="datepicker/tests/jquery.1.9.1.js"></script>
<script src="datepicker/lib/picker.js"></script>
<script src="datepicker/lib/picker.date.js"></script>
<script src="datepicker/lib/legacy.js"></script>
<script type="text/javascript">
//datepicker
// take dates as array of strings from db
var ddates_str_arr = [ <?php echo $js_ddates; ?> ];
// build dates array for picker
var disdates = [];
for (var i = 0; i < ddates_str_arr.length; i++) {
disdates.push(new Date(ddates_str_arr[i]));
}
var $input = $( '.datepicker' ).pickadate({
formatSubmit: 'yyyy/mm/dd',
min: true,
container: '#container',
// editable: true,
closeOnSelect: true,
closeOnClear: false,
disable: disdates
});
var picker = $input.pickadate('datepicker')
</script>
<script src="jquery-1.9.0.min.js"></script>
<div class="cascade" id="products"></div>
<div id="employees" class="cascade"></div>
<div id="res_time" class="res_time"></div>
</div>
<div class="contact-right1">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<button id="save" class="button_example">Done</button></div>
</form>
</div>
</div>
<script src="jquery-1.9.0.min.js"></script>
<script>
$(document).ready(function(){
$("#savecascade").submit(function(){
var get_data=$("#savecascade").serialize();
$.ajax({
type: "POST",
url: "inser_data.php",
data: {"csc":get_data},
cache: false,
success: function(html) {
alert(html);
}
});
return false;
});
change(function(){
var categories_id = picker;
// alert(categories_id);
$("#products").html( "" );
$("#employees").html( "" );
$("#res_time").html( "" );
$.ajax({
type: "POST",
url: "fetch_products.php",
data: "categories_id="+categories_id,
cache: false,
beforeSend: function () {
$('#products').html('<img src="loader.gif" alt="" width="24" height="24">');
},
success: function(html) {
$("#products").html( html );
}
});
}
});
});
</script>
</body>
</html>
原谅我凌乱的代码,我有一个链式的ajax盒子,它不会进入第二个盒子,因为我先放一个日期选择器,为什么第二次下拉不起作用?我想我不是从它发送数据。如何将数据发送到fetch_products.php
答案 0 :(得分:1)
尝试:
$.ajax({
type: "POST",
url: "fetch_products.php",
data: {categories_id:$('#drop1').val()},
cache: false,
beforeSend: function () {
$('#products').html('<img src="loader.gif" alt="" width="24" height="24">');
},
success: function(html) {
$("#products").html( html );
}
});
}