0

Sir I have these codes

   <input  type="text" size="11" name="f_date1"
   id="datepicker-13" value="<?php echo date('d-m-Y', strtotime($f_date1));?>"/>

    <input type="text"   size="11" name="t_date1"
    id="datepicker-133" value="<?php echo date('d-m-Y', strtotime($t_date1));?>"/>

    <script>
    var ja = jQuery.noConflict();
    ja(document).ready(function() {
        ja("#datepicker-133").datepicker({dateFormat:'dd-mm-yy'}).on("change",function(){

            var f_date1 = $("#datepicker-13").val();
            var t_date1 =$("#datepicker-133").val();

            var data = {
                ff_date1: f_date1,
                tt_date1: t_date1
               }

alert(data)

            $.ajax({
                url: "ajax_ledg_summ.php",
                data: data,
                success: function(msg) {
                    $("#table-container").html(msg);
                }
            });
        });
    });
</script>

and ajax_ledg_summ.php has this data

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

include_once("includes/connectsql.php");

if(isset($_GET["ff_date1"]) and isset($_GET["tt_date1"]))
{

$f_date1=$_GET["ff_date1"];
$t_date1=$_GET["tt_date1"];

$f_date1=date('Y-m-d', strtotime($_GET["ff_date1"]));
$t_date1=date('Y-m-d', strtotime($_GET["tt_date1"]));
...
...
....

when I run codes it displays nothing, I think the problem is in these codes

 if(isset($_GET["ff_date1"]) and isset($_GET["tt_date1"]))
    {

    $f_date1=$_GET["ff_date1"];
    $t_date1=$_GET["tt_date1"];

May be I am wrong,
Please help

2
Contributors
1
Reply
15
Views
9 Months
Discussion Span
Last Post by pty
1

I'm no PHP expert, so forgive my ignorance.

If you test in a basic manner, rather than by using AJAX, what happens? By using your browser's inspector, you can see that doing:

$.ajax({
  url: "my_service",
  data: {f_date1: "yesterday", t_date1: "today"},
  success: function(msg) {
    console.debug("yay")
  }
});

will result in a GET request like this:

my_service?f_date1=yesterday&t_date1=today

If you paste that into a browser's URL bar (or better yet use something like HTTPie or Postman), you can make sure that you can access the query string properly. Once you know that works, and you know that jQuery's .ajax method does the same thing, you'll have a much better chance at solving your problem.

Edited by pty

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.