2016-03-31 36 views
0

PHPの値を返し、HTMLテーブルをアセンブルするJavaScriptコードがあります。エラーを与えることは、それぞれ未定義のプロパティを読み取ることができません。私は何度も成功しなかった。彼らは私に手を差し伸べるだろうか? 次のコードエラー:未定義の 'each'プロパティを読み取ることができません

のJavaScript:

function getListaItems(idprojeto) { 
 
    //alert(idprojeto); 
 
\t jQuery.ajax({ 
 
\t \t type: "POST", 
 
\t \t url: "get-lista-items.php?idprojeto=" + idprojeto, 
 
\t \t //data: dataEvento, 
 
\t \t dataType: 'json', 
 
\t \t success: function(resposta) { 
 
\t \t \t var str_html = ''; 
 
\t \t \t $.each(resposta, function(){ 
 
\t \t \t \t 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>'; 
 
\t \t \t }); 
 

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

PHP:

<?php 
 

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

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

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

 
?>

Tハンクス、みんな。

+1

'それは働いた' jQuery' – dandavis

+0

と$ 'を交換してください。ありがとうございました! –

答えて

1

jQueryは$を使用して利用できません。代わりにjQueryを試してください。

変更この行:これまで

$.each(resposta, function(){ 

jQuery.each(resposta, function(){ 
関連する問題