jQuery Datepicker来触发POST [英] jQuery Datepicker to Trigger a POST

查看:118
本文介绍了jQuery Datepicker来触发POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jquery UI的datepicker触发POST,然后从数据库中的datepicker选择的日期加载信息。

i want to use jquery UI's datepicker to trigger a POST that would then load information from the date picked on the datepicker from my database.

所以我猜这是一个两部分的问题

so i guess this is a two-part question

有没有办法,我可以使它的datepicker日期,当选择,只是被传递到一个POST,所以有人会点击jan 1 2010年,它会自动转到mysite.com?date=01012010或类似于
的方式,现在的datepicker只是更新一个文本框与日期,所以点击2010年1月1日,文本框是填充01-01-2010

is there a way i can make it so the datepicker date, when selected, just gets passed into a POST, so someone would click on jan 1 2010 and it would automatically go to mysite.com?date=01012010 or something like that the way it is now the datepicker just updates a text box with the date, so upon clicking on jan 1 2010, the text box is populated with 01-01-2010

这带给我第2部分
如果没有办法做我在第1部分问的,是否有一种方法这将触发一个事件在正在更新的文本框,这样我只能做

which brings me to part 2 if there is no way to do what i asked in part 1, is there a method that triggers an event on the text box being updated, that way i could just do

onTextUpdate {

onTextUpdate{

重定向到 - mysite.com?date=$whateverIsInTextBox

redirect to - mysite.com?date=$whateverIsInTextBox

}

或类似的东西

请让我知道,如果有的话任何解决方案或想法要做,谢谢你很多

please let me know if you have any solutions or ideas to do this, thanks a lot

推荐答案

如果你不想使用ajax:

You could do something like this if you don't want to use ajax:

$("#datepicker").datepicker({

    onSelect: function(date, instance) {
            window.location = "www.example.com/?date="+date;
    }
});

如果你这样做:

$("#datepicker").datepicker({

    onSelect: function(date, instance) {

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

这篇关于jQuery Datepicker来触发POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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