Notice: Undefined index - error when trying to perform a $_POST in controller (MVC)

Asked

Viewed 22 times

0

I’m trying to make a dynamic combobox with html, php and javascript.

To do this, I need to send the selected value in the first select (View) to my Controller file, but the following error occurs:

Notice: Undefined index: categid in C: xampp2 htdocs testes Catalog controller Account customerpartner addproduct.php

Could someone help me solve this mistake? Follow the codes.

JAVASCRIPT:

<script>

$(document).ready(function(){

         $("select[name=product-category]").change(function(){
            $("select[name=product-subcategory1]").html('<option value="">Carregando...</option>');

            $.post("catalog/controller/account/customerpartner/addproduct.php",
                  {categid:$(this).val()},
                  function(valor){
                     $("select[name=product-subcategory1]").html(valor);
                  }
                  )

         })
      })

</script>

PHP

if ($_POST["categid"]) {
    $categid = $_POST['categid'];
}

Thanks in advance for the help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.