关于bootstrap日历插件传值到后台的问题

今日再做一个时间保存到数据库中的东西,所用的是bootstrap的日历插件,但是存在的一个问题是如何将所选时间传值到后台的action中,尝试了多种方法始终达不到想要的效果,最终经过偶然发现可以使用ajax的异步传输将所需要的数据传递到后台。

我的代码为:

日期插件代码:

<div class="controls">
 <div class="input-prepend input-group">
   <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
入住日期-退房日期</span><input type="text" readonly style="width: 200px" name="reservation" id="reservation" class="form-control" value="2018-6-21-2018-6-28" /> 
</div>
</div>

传值到后台的代码为:

<script type="text/javascript">
	$(document).ready(function() {
		//按钮点击事件
		$("#submit").click(function() {
		//发起异步请求//参数一:请求的地址;参数二:传递的参数;参数三:回调函数,接收服务器回传的数据
		$.post("customervalue.action", {"reservation" : $("#reservation").val()});});});
</script>



猜你喜欢

转载自blog.csdn.net/dfsethtdfd/article/details/80843331