Ajax post undefined index in php
<p>I have 2 php file. One Php file uses ajax to post something to another php file.</p>

<p>Let's say Php 1 is called index.php while the other php is getsomething.php</p>

<p>Here's my index.php code with ajax(only part of the code is given here)</p>

<pre><code>$(function() {
  $("#datestart").on("change", function() {
     var d = new Date();
     var n = d.getFullYear();
     var dte = new Date(n, $(this).val(), 0).getDate();
     var datestart = n + "-" + $(this).val() + "-01 00:00:00";
     var dateend   = n + "-" + $(this).val() + "-" + dte + " 23:59:59";
     var brandid   = $('#txtbxbrandid').val();

     //-----GENDER----//
     $.ajax({ url: 'ajax/datagenderfilter.php',
         dataType:'json',
         type: 'post',
         data: {'bidg' : brandid, 'startg' : datestart, 'stopg' : dateend},

          success: function(output) {

          $('#chartContainergender').remove();
          $('#chartgender').append('&lt;div id="chartContainergender" style="height: 300px; width: 100%;"&gt;&lt;/div&gt;');
          var chartgender = new CanvasJS.Chart("chartContainergender",
            {
                title:{
                    text: "Pie chart filtered by Gender"
                },
                legend: {
                    maxWidth: 350,
                    itemWidth: 120
                },
                data: [
                {
                    type: "pie",
                    showInLegend: true,
                    legendText: "{indexLabel}",
                    dataPoints: output
                }
                ]
            });
            chartgender.render();
          },
          error: function(request, status, error){
            alert("Error: Could not delete");
          }
      });


   });
});
</code></pre>

<p>Now here's the getsomething.php</p>

<pre><code>if (isset($_POST['bidg'])) {
$brandid = $_POST['bidg'];
$datebeg = $_POST['startg'];
$dateend = $_POST['stopg'];

echo json_encode($brandid, JSON_NUMERIC_CHECK);
}
else{
  echo json_encode("FAILED", JSON_NUMERIC_CHECK);
}
</code></pre>

<p>But everytime I tried posting it the getsomething.php skips the if and go straight to else.</p>

<p>Can someone check where am I going wrong.</p>