Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sara Alves

Erro macabro .done is not a function

Recommended Posts

Olá amigos,

Tenho o seguinte codigo

 

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Xtart</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript">
	$(document).ready(function() {
		var url = "http://xt.art.br/br.art.xt.xtart/API/";
		$("#news").html("");
		var mostrados = 5;
		$.getJSON(url, function(data) {
			$.each(data.members, function(i, user) {
				var tblRow = "<div class='posts' style='background-image: url(" + user.guid + "?zoom=2&resize=640%2C360);'>" + "<input type='hidden' value='" + user.ID + "'/>" + "<div class='post_title'><div>" + user.post_title + "</div></div>" + "</div>";
				$(tblRow).hide().appendTo("#news");
			}).done(function() {
				var filhos = $('#news').children('.posts');
				for (var i = 0; i < mostrados; i++) {
					filhos[i].className = "posts show";
				}
				$(window).scroll(function() {
					if($(this).scrollTop() + $(this).height() === $(document).height()) {
						var mostradosAntes = mostrados;
						mostrados += 5;
						var filhos = $('#news').children('.posts');
						for (var i = mostradosAntes; i < mostrados; i++) {
							filhos[i].className = "posts show";
						}
					}
				});
			});
		});
	});
  </script>
  <style type="text/css">
    #news {
      float: left;
      width: 100%;
    }
    .posts {
      float: left;
      width: 100%;
      height: 200px;
      margin-bottom: 10px;
      background-position: center;
      background-size: cover;
    }
    .post_title {
      margin-top: 120px;
      height: 80px;
      background-image: url(bg_post_title.png);
      background-repeat: repeat;
    }
    .post_title div {
      color: #FFFFFF !important;
      padding: 2px;
      text-transform: uppercase;
      text-shadow: 1px 1px #444
    }
    .show {
      display: block;
    }
    
    .hide {
      display: none;
    }
  </style>
</head>

<body>
  <div id="news"></div>
</body>

</html>

Ele tem a funcão de resgatar valores json em uma api e me trazer os resultados, porém está ocorrendo o segi
 

Citar

Uncaught TypeError: $.each(...).done is not a function (Linha 16)


Já verifiquei tudo e simplesmente não consigo ver aonde está o erro, se tiver alguém ai com zoi de águia e puder me ajudar, obrigado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Obrigado amigo, fiz a mudança e o erro no depurador parou, porém o script não esta me mostrando os resultados, poderia me dar um auxilio do porque não estou recebendo os resultados? aonde pode está o erro, obrigado.

ficou assim

 

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Xtart</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript">
	$(document).ready(function() {
		var url = "http://xt.art.br/br.art.xt.xtart/API/";
		$("#news").html("");
		var mostrados = 5;
		$.getJSON(url, function(data) {
			$.each(data.members, function(i, user) {
				var tblRow = "<div class='posts' style='background-image: url(" + user.guid + "?zoom=2&resize=640%2C360);'>" + "<input type='hidden' value='" + user.ID + "'/>" + "<div class='post_title'><div>" + user.post_title + "</div></div>" + "</div>";
				$(tblRow).hide().appendTo("#news");
			});
		}).done(function() {
			var filhos = $('#news').children('.posts');
			for (var i = 0; i < mostrados; i++) {
				filhos[i].className = "posts show";
			}
			$(window).scroll(function() {
				if($(this).scrollTop() + $(this).height() === $(document).height()) {
					var mostradosAntes = mostrados;
					mostrados += 5;
					var filhos = $('#news').children('.posts');
					for (var i = mostradosAntes; i < mostrados; i++) {
						filhos[i].className = "posts show";
					}
				}
			});
		});
	});
  </script>
  <style type="text/css">
    #news {
      float: left;
      width: 100%;
    }
    .posts {
      float: left;
      width: 100%;
      height: 200px;
      margin-bottom: 10px;
      background-position: center;
      background-size: cover;
    }
    .post_title {
      margin-top: 120px;
      height: 80px;
      background-image: url(bg_post_title.png);
      background-repeat: repeat;
    }
    .post_title div {
      color: #FFFFFF !important;
      padding: 2px;
      text-transform: uppercase;
      text-shadow: 1px 1px #444
    }
    .show {
      display: block;
    }
    
    .hide {
      display: none;
    }
  </style>
</head>

<body>
  <div id="news"></div>
</body>

</html>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por ILR master
      Pessoal, pergunta bem simples. Abaixo tenho o seguinte código:
       
      <script>
      function alerta()
      {
        if (window.confirm("Você realmente quer sair?")) {
          window.open("sair.html");
      }
      }
      </script>
       
      Funciona perfeitamente, só que está abrindo em outra janela e quero que abra na mesma janela.
       
      Alguém pode me ajudar?
    • Por Giovanird
      Olá a todos!
      Tenho uma pagina que possui uma DIV onde coloquei uma pagina PHP.
      Uso a função setInterval para atualizar a pagina inclusa dentro da DIV.
      O problema é que ao acessar o site , a DIV só me mostra a pagina inclusa somente quando completo o primeiro minuto.
      Preciso que a pagina inclusa já inicie carregada
       
      Meu código JavaScript e a DIV com a pagina PHP
       
      <script> function atualiza(){ var url = 'direita.php'; $.get(url, function(dataReturn) { $('#direita').html(dataReturn); }); } setInterval("atualiza()",60000); </script> <div> <span id="direita"></span> </div>  
    • Por Thiago Duarte
      Oi, gostaria de arrastar imagem e ao soltar formar bloco html, meu bloco de html ficaria com nome, content-1.html, content-2.html, etc
       
      Alguem pode me ajudar?
    • Por belann
      Olá!
       
      Estou fazendo o upload de arquivos com fetch dessa forma
      fetch(url, {
              method: 'POST',
              headers: {'Content-Type': 'multipart/form-data',},
              body: formData 
          }).catch((error) => (console.log("Problemas com o Upload"), error));
       
      estou usando input type=file
      e criando uma const formData = new FormData(); 
      mas não faz e não dá nenhum erro.
      estou fazendo o upload com a url="http://localhost/dashboard/dados".
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.