如何在php MVC框架中使用ajax调用替换jcarousel slider html
在我的php web应用程序中有两个jcarousel滑块,一个用于选择月份,另一个用于与该月份相关的日期,我想使用jquery ajax来实现,如何在php MVC框架中使用ajax调用替换jcarousel slider html,php,jquery,json,Php,Jquery,Json,在我的php web应用程序中有两个jcarousel滑块,一个用于选择月份,另一个用于与该月份相关的日期,我想使用jquery ajax来实现, 无论我选择的是哪个月,所有日期都应该出现在第二个滑块中,是否有任何方法请提供帮助。首先设置月份和日期基本html <ul id="months" class="jcarousel-skin"> <li>Jan</li> <li>Feb</li> <li>M
无论我选择的是哪个月,所有日期都应该出现在第二个滑块中,是否有任何方法请提供帮助。首先设置月份和日期基本html
<ul id="months" class="jcarousel-skin">
<li>Jan</li>
<li>Feb</li>
<li>Mar</li>
<li>Apr</li>
<li>May</li>
<li>Jun</li>
<li>Jul</li>
<li>Aug</li>
<li>Sep</li>
<li>Oct</li>
<li>Nov</li>
<li>Dec</li>
</ul>
<ul id="dates" class="jcarousel-skin">
</ul>
- 一月
- 二月
- 玷污
- 四月
- 五月
- 六月
- 七月
- 八月
- 九月
- 十月
- 十一月
- 十二月
现在在javascript中设置月份旋转木马和日期ajax
$(document).ready(function(){
$('#months').jcarousel();
// Assuming you are going to load months' dates onclick
$('#months > li').click(function(){
$.ajax({
url : 'your-server-script.php?month=' . $(this).text(),
success : function(data){
/* Return the dates as html in li tags from server
<li>1, Friday</li><li>2, Saturday</li> .... <li>30, whatever</li>
and put in the dates ul.
You can also pass json(or any other format) and create the html here and put it in.
*/
$('#dates').html(data);
// Now setup the dates carousel.
$('#dates').jcarousel();
}
});
});
});
$(文档).ready(函数(){
$(“#月”).jcarousel();
//假设您要在单击时加载几个月的日期
$(“#月>里”)。单击(函数(){
$.ajax({
url:'您的服务器脚本.php?月='。$(this).text(),
成功:功能(数据){
/*从服务器以html格式返回li标记中的日期
星期五,星期六,星期六,30,随便什么
把日期放进去。
您还可以传递json(或任何其他格式)并在此处创建html并将其放入。
*/
$('#dates').html(数据);
//现在设置日期转盘。
$(“#日期”).jcarousel();
}
});
});
});
希望这有帮助。如果您还有更多问题,请与html一起粘贴。下面是我的javascript代码$.ajax({type:“GET”,url:url,dataType:“html”,data:“month=”+monthCount.i,success:function(data){$(“#datas content week days').html(data);$(“#datas content week days”).jcarousel();},错误:函数(错误){console.log(“错误:”;console.log(错误);});在使用ajax调用代码之后,我的日期jcarousel滑块没有正常滑动,而在ajax调用之前,它没有正常滑动。请帮个忙…嗯…,好像有用。请在中设置,共享链接。