David19801
David19801

Reputation: 11448

jquery datepicker ajax

I am trying to send an ajax request immediately after a date is chosen with the jquery datepicker.

I have:

<script>
    $(function() {
        $( "#datepicker" ).datepicker({dateFormat: "dd-mm-yy" });
    });

var sentdate=("#datepicker").val();
$.ajax({
  url: "callthephp.php?d="+sentdate,
 success: function(data) {
    $("#output").html(data);
  }
});

</script>

<div class="demo">
<p>Date: <input id="datepicker" type="text"></p>
</div>

<div class="output">
</div>

Any ideas how I get this working?

Upvotes: 2

Views: 1053

Answers (1)

Igor
Igor

Reputation: 33963

Fire the ajax call using the onSelect event of the datepicker.

Upvotes: 5

Related Questions