I was working on populate dropdown with jquery ajax, i've got this error
Notice: Undefined index: categid in C:\xampp\htdocs\PopuTry\popucon.php on line 9
here's the code
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database="maindb";
$names =$_POST['categid'];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);
$output='';
$sql ="Select * From tbl_stocks Where Category = '".$names."'";
$result = mysqli_query($conn,$sql);
$output='<option value="">Select Menu</option>';
while($row=mysqli_fetch_array($result))
{
    $output .='<option value="'.$row["Menu_Number"].'">'.$row["Name"].'</option>';
}
echo $output;
?>
the $names code is where the error thrown, 
here's my html code
    <?php
include('popucon.php');
function loadCateg()
{
    $servername = "localhost";
    $username = "root";
    $password = "";
    $database="maindb";
// Create connection
    $conn = mysqli_connect($servername, $username, $password, $database);
    $output ='';
    $sql = "select * from tbl_category";
    $result = mysqli_query($conn,$sql);
    while($row = mysqli_fetch_array($result))
    {
        $output .='<option value-"'.$row["cat_id"].'"">'.$row["Category"].'</option>';
    }
    return $output;
}
?>
<html>
<head>
    <title>Try1 Populate</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
    <p>Select Category
    <select name="categ" id="categ">
        <option value="">Select Category</option>
        <?php echo loadCateg(); ?>
    </select></p>
    <p>Select Menu
        <select name="menu" id="menu">
            <option value="">Select Menu</option>
        </select></p>
</body>
</html>
<script>
    $(document).ready(function(){
        $('#categ').change(function(){
            var categ_id = $(this).val();
            $.ajax({
                url:"popucon.php",
                method:"POST",
                data:{categid:categ_id},
                dataType:"text"
                success: [ function (data)
                {
                    $('#menu').html(data);
                }
                ]
            });
        });
    });
</script>
The data:{categid:categ_id}, is where the categid $_POST declared.
can anyone help me? thanks!
 
     
     
    