Your JS looks fine, although it could be simplified a bit:
- $(function() {
- $('#sdatepicker,#edatepicker').datepicker({
- dateFormat: 'yy-mm-dd',
- constrainInput: false
- });
- $("#generate_log").click(function() {
-
jQuery.ajax({
- type: 'POST',
- url: 'test.php',
- data:
{
- sdatepicker:
$('#sdatepicker').val() + ' 00:00:00',
- edatepicker:
$('#edatepicker').val() + ' 23:59:59'
- },
-
success: function(response) {
-
}
- });
- });
- });
The problem appears to be in your PHP. You are using the variables
$sdatepicker and $edatepicker in your query, but these
haven't been defined anywhere.