Jquery获取/发布

Jquery get/post

本文关键字:发布 获取 Jquery      更新时间:2023-09-26

如何使用jquery发布日期?我使用jquery日期时间选择器。我从日期时间选择器中获得日期。现在想像一样发布

localhost/rnd/event.php?日期=2012年12月12日

在同一页中,我想获得的post/get值

<?php
if (isset($_GET['date'])) {
    echo "got the posted date";
}
?>

以下是我如何从日期时间选择器获取日期

$(function () {
    var pickedDate = $("#datepicker").datepicker({
        onSelect: function () {
            var day = $(this).datepicker('getDate').getDate();
            var month = $(this).datepicker('getDate').getMonth();
            var year = $(this).datepicker('getDate').getFullYear();
            var OutString = day + " - " + month + " - " + year;
        }
    });
});

使用$.get:

$.get('event.php', { date: OutString }, function(result) {
    // do something with the PHP script's output
});

通常,您应该使用"get"来查询数据,并使用"post"来提交数据。

就像Jon说的:

$.get('event.php', { date: OutString }, function(result) {
    // do something with the PHP script's output
});

$.post('event.php', { date: OutString }, function(result) {
    // do something with the PHP script's output
});