簡體   English   中英

jQuery的獲取/發布

[英]Jquery get/post

我如何使用jquery發布日期?我使用jquery datetimepicker凸輪。我從datetime選擇器中獲取了日期。

本地主機/rnd/event.php?date=12-12-2012

在同一頁面中,我想獲取post / get的值

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

這是我如何從datetimepicker獲取日期

$(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('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
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM