Error: Can not read property 'each' of undefined [closed]

1

I have a JavaScript code that returns values from a PHP and assembles an HTML table. You are giving the error Can not read property 'each' of undefined . I've looked several times to no avail. Could you give me a hand? Here is the code:

JavaScript:

function getListaItems(idprojeto) {
  //alert(idprojeto);
	jQuery.ajax({
		type: "POST",
		url: "get-lista-items.php?idprojeto=" + idprojeto,
		//data: dataEvento,
		dataType: 'json',
		success: function(resposta) {
			var str_html = '';
			$.each(resposta, function(){
				str_html = str_html + '<tr class="gradeA" id="' + this.id + '">' +
        '<td class="center"><input type="checkbox"  id="item[]" name="item[]" onchange="changeColor(' + this.id + ')" value="' + this.id + '" /></td>' +
        '<td class="center">' + this.descricao + '</td>' +
        '<td class="center">' + this.descCategoria + '</td>' +
        '<td class="center">' + this.descCaracteristica + '</td>' +
        '<td class="center">' + this.descMedida + '</td>' +
        '<td class="center"><input type="text" id="qtd' + this.id + '" style="width:80px"/></td>' +
        '</tr>';
			});

			document.getElementById("resultJs").innerHTML = str_html;
		}
	});
}

PHP:

<?php

	session_start();
	require_once("ProjectIncludes.php");

	$service = new ProjetoxItensService();
	$consulta = $service->getAll($_GET['idprojeto']);

	$retorno = json_encode($consulta);
	echo $retorno;

?>

Thank you in advance.

    
asked by anonymous 31.03.2016 / 21:39

1 answer

3

Use jQuery.each instead of $.each . It appears that the $ alias does not exist in your program.

    
31.03.2016 / 21:51