What does callback.call mean in jQuery?

0

I searched everywhere but did not find an exact definition.

Here's my function and the excerpt from my HTML where DropDownList is created:

function carregaSubCategoria(valor) {
  $.ajax({
    url: '/parceiros/subcategoria/lists-subcat',
    type: 'get',
    data: {
      id: valor
    },
    dataType: 'JSON',

    success: function(data) {
      var $teste = $('#subcategoria');

      $teste.empty();
      $teste.append($("<option></option>").attr("value", '').text('Selecione'));
      $teste.each(data, function(value, key) {
        $teste.append($("<option></option>").attr("value", value).text(key));
      });
    },
    error: function(data) {
      alert("oi errado");
    },
  });
}
<div id="div_categoria">
    <label class="label-control">Categoria</label>
    <select name="ofe_cat_id" id="ofe_cat_id" class="form-control" onchange="carregaSubCategoria($(this).val())">
        <option value="">Selecione</option>
        <?php foreach ($categorias as $categoria) {
            echo "<option value='".$categoria->cat_id."'>".$categoria->cat_nome."</option>";
        } ?>
    </select>
</div>

<div id="div_subcategoria">
    <label class="label-control">Subcategoria</label>
    <select name="subcategoria" id="subcategoria" class="form-control">
        <option value="">Selecione</option>
        <?php foreach ($subcategorias as $subcategoria) {
            echo "<option value='".$subcategoria->sub_id."'>".$subcategoria->sub_nome."</option>";
        } ?>
    </select>
</div>

Here's a portion of the JSON file:

[  
   {  
      "sub_id":2,
      "sub_cat_id":3,
      "sub_cod":"00020002",
      "sub_nome":"Terror",
      "sub_desc":"Filmes de Terror"
   },
   {  
      "sub_id":3,
      "sub_cat_id":3,
      "sub_cod":"00030003",
      "sub_nome":"Aventura",
      "sub_desc":"Filmes de Aventura"
   }
]

I'm trying to run this code, but it keeps bringing me the error:

  

TypeError: callback.call is not a function

    
asked by anonymous 18.10.2018 / 18:34

0 answers