0
I’ve searched everywhere but can’t find an exact definition.
Follow my function and the snippet of 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>
Follow a part 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
You can post a snippet of your JSON file and a snippet of your HTML that contains your tag with
id
"subcategory"?– Pedro Gaspar
Ready, added.
– Victor Augusto
And an excerpt from the JSON file?
– Pedro Gaspar
Where you’re being called
call
? Probably refers toFunction.prototype.call
which is a native javascript function and is available in all functions– Costamilam
The
call
is from a Jquery I took, from a ready-made layout, to activate some classes of boostrap.– Victor Augusto
JSON added also
– Victor Augusto
So add this jQuery that got, after all the origin of the problem is in it
– Costamilam
For now I commented on jQuery’s call from the entire site (the file has more than 10,000 lines of code), the problem has stopped, and the Dropdownlists are working, but in return, some layout features have been undone. I’m new in the area and I don’t understand much, but I think it’s easier I set up a layout and a jQuery of my own than trying to set up this whole file, no??
– Victor Augusto
tries like this: $teste.each(Function(value, key) { $teste.append($("<option></option>"). attr("value", value). text(key); });
– aa_sp