如何在datepicker更改日期时使用ajax发布? [英] How use ajax post when datepicker change date?

查看:94
本文介绍了如何在datepicker更改日期时使用ajax发布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好

使用datepicker ui输入更改的值。

Value in input change with datepicker ui.

我想在值时使用ajax post输入将改变。

I want use ajax post when value in input will be change.

为此我使用脚本:

<input type="text" name="date" class="datepicker" id="datepicker">

$(".datepicker").datepicker({changeYear: true});

$(".datepicker").on("change",function(){
var date=$(this).val();
$.post("test.php", {
date:date
},
function(data){$('#testdiv').html('');$('#testdiv').html(data);
});
});

但是ajax post查询是用旧日期执行的。

But ajax post query is executed with the old date.

Datepicker在输入中没有时间更改值。

Datepicker does not have time change value in input.

告诉我在datepicker更改字段中的日期后如何进行查询?

Tell me how to do query after datepicker change the date in the field?

我需要:

1)datepicker更改日期;

1) datepicker change the date;

2)查询应该与新日期一起发送。

2) query should be send with new date.

推荐答案

你可以在datepicker事件上触发ajax帖子:

You can trigger ajax post on datepicker events:

$("#datepicker").datepicker({

    onSelect: function(date, instance) {

        $.ajax
        ({
              type: "Post",
              url: "www.example.com",
              data: "date="+date,
              success: function(result)
              {
                  //do something
              }
         });  
     }
});

希望这有帮助 - @Codebrain

Hope this helps- @Codebrain

这篇关于如何在datepicker更改日期时使用ajax发布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆