在页面加载时将jquery日期选择器数据发送到php

在页面加载时将jquery日期选择器数据发送到php,php,javascript,jquery,jquery-ui-datepicker,Php,Javascript,Jquery,Jquery Ui Datepicker,我正在使用jquery日期选择器 <form action="" method="get" name="date"> <br /> Start Date :<input type="text" name="sdate" id="sdate" /> End Date : <input type="text" name="edate" id="edate" /> </form> 您应该提供一个函数来获取日期并进行A

我正在使用jquery日期选择器

<form action="" method="get" name="date">
    <br />
    Start Date :<input type="text" name="sdate" id="sdate" />
    End Date : <input type="text" name="edate" id="edate" />
</form>

您应该提供一个函数来获取日期并进行Ajax调用,或者如果您希望同时发送这两个日期,您应该将这两个日期存储在变量中,然后在第二个日期关闭时进行Ajax调用

$("#sdate").datepicker({
   "dateFormat" : "yy-mm-dd",
   "onClose": function(date, obj){
        jQuery.post('URL', {sDate: date}, function(data, textStatus, xhr) {
             //If there is success
        });
   }
});
$("#edate").datepicker({
   "dateFormat" : "yy-mm-dd",
   "onClose": function(date, obj){
        jQuery.post('URL', {eDate: date}, function(data, textStatus, xhr) {
             //If there is success
        });
   }
});

$("#edate").datepicker("setDate","+0");
$("#sdate").datepicker("setDate","-7");

您好,您可以在close函数中使用AJAX调用

onClose: function() {
        //do ajax call here 
$.ajax({
      url: "test.php",
      type: "post",
      data: values,
      success: function(){
          alert("success");

      },
      error:function(){
          alert("failure");

      }   
    }); 
      }

如果你的日期选择器是表单的一部分,你可以这样做

onSelect: function (dateText, inst) {
 $(this).parent('form').submit();
        }
这将提交父窗体

更多信息请点击这里

这里有更多帮助…几乎相同的问题


我在您的代码中没有看到任何提交按钮,因为我不想要提交按钮。我想在没有提交按钮的情况下完成它。
onSelect: function (dateText, inst) {
 $(this).parent('form').submit();
        }