【发布时间】:2017-11-01 04:46:28
【问题描述】:
我试图用其他主题的答案来解决这个问题,但我不能,我的浏览器控制台中只有一个错误,但一切正常:
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in
false
这里是我的 JS:
$("select[name=categoria]").change(function(){
valorBuscar = $(this).val();
mostrarDatos2(valorBuscar);
});
}
function mostrarDatos2(valorBuscar){
$.ajax({
url : "http://localhost/empresa/CategoriaC/mostrarCat",
type: "POST",
data: {categoria: valorBuscar},
dataType:"json",
success:function(response){
filas = "";
$.each(response.cat,function(key,item){ //<= here is the error
filas+="<tr><td><input type='checkbox' id='check'
value="+item.correo+"></td><td>"+item.contacto+"<br
/>"+item.correo+"<br />"+item.nombre_empresa+"</td></tr>";
});
$("#tbclientes tbody").html(filas);
}
});
}
【问题讨论】:
-
可能 response.cat 是假的
-
那么哪一行导致了这个错误?语法看起来无效,所以我很惊讶这完全有效
-
如果你有一个错误,那么一切是不是好的
-
您是否收到任何带有该错误的堆栈跟踪?
-
尝试记录
response.cat并查看您得到的响应
标签: javascript jquery ajax