在日期选择器更改后更新行中的日期字段


Update date field in a row after datepicker change

我有一个表,其中包含一列可以通过日期选择器更改的日期。

<td>
   <div class="input-group date" data-provide="datepicker">
        <input type="text" class="form-control" name="dataPrevisao" id="dataPrevisao" rel="<?php echo odbc_result($resultado,"stamp");?>" value="<?php echo odbc_result($resultado,"dvalor");?>" />
        <div class="input-group-addon">
             <span class="glyphicon glyphicon-calendar small"></span>
        </div>
   </div>

我想做的是,在更改日期后,寄存器会自动更新到表中。为此,我有一个php文件-changePrevisao.php:

<?php include("includes/odbc.ini"); 
$iniciais=str_replace(' ', '', $_SESSION['iniciais']);
$stamp=$_POST['stamp']; 
$dataP=$_POST['dataP']; 
$query = "  update od set marcada=1, data='$dataP', usrdata=convert(varchar(10),getdate(),112),
            usrhora=right(convert(varchar(19),getdate(),121),8), usrinis='$iniciais' where od.odstamp='$stamp'";
odbc_exec($sqlconnect,$query); 
?>

我在向ajax构建允许将数据传递到php文件的用户函数时遇到了问题,有人能帮我吗?

经过搜索和测试,我创建了以下函数:

<script>
    $(document).ready(function(){
    $(document).on('change', '#dataPrevisao', function () {
        var stamp = $(this).attr('rel');
        var dataP = $(this).val();
        var dataString = 'stamp='+ stamp +'&dataP='+ dataP;
        $.ajax({
            type: "POST",
            url: "changePrevisao.php",
            data: dataString,
            cache: false,
            success: function(new_data){
                    $(stamp).html(new_data);
                    $(stamp).dialog();
                    alert('Load was performed.');
    }
   });
  });
});
</script>

现在我可以更新数据库中的日期,但结果并不像我预期的那样,只有当我直接更改输入而不是通过日期选择器时才会发生更改。我需要在函数中更改什么,以便将日期选择器所做的更改考虑在内?