retorno de post
bom to com um probleminha com o post do jquery, eu faço a consulta em meu arquivo php, e retorno a consulta caso ele for diferente de vazio, porem o post esta imprimindo a resposta como vazio "", ai vai aumentando as linhas no html, ate ai nenhum problema, mas depois que aumenta as linhas e eu receber uma consulta com conteudo ele imprime a consulta varias vezes, tipo se ele tiver imprimido 10 em branco "" quando gerar a consulta e tiver retorno ele imprime 10 campos da consulta, alguem tem uma ideia
função java script que estou usando
$(document).ready(function(){
$(function() {
teste.teste()
});
teste = {
teste:function()
{
var id_first = $('.classe_status:first').attr('id');
$.post('jquery/atualiza_atualizacoes.php',{id_first:id_first},function(retorno){
if(retorno!="")
{
alert(retorno)
$('#div_mostra_status').prepend(retorno)
}
});
setInterval("teste.teste()",60000)
}
}
});
arquivo php
$retorno="";
$id_first=limpa_sql($_POST['id_first']);
$sql="select * from tpm_perfil_status where TPMps_id>".$id_first." && (TPMps_id_perfil=(select TPMpa_id_amigo from tpm_perfil_amigos where TPMpa_id_amigo1=".$_SESSION['perfil_profile'].") || TPMps_id_perfil=(select TPMpa_id_amigo1 from tpm_perfil_amigos where TPMpa_id_amigo=".$_SESSION['perfil_profile'].")) order by TPMps_id asc";
if($resultado_status=$con->banco->SelectLimit($sql,40,0))
{
while(!$resultado_status->EOF)
{
$id=$resultado_status->fields['TPMps_id_perfil'];
$sql="select * from tpm_perfil where TPMpe_id=".$id;
$resultado_mostra_foto=$con->banco->Execute($sql);
$data=$resultado_status->fields['TPMps_postagem'];
$data=explode(" ",$data);
$data= implode('/',array_reverse(explode('-',$data[0]))).' '.$data[1];
$retorno=$retorno.'<div style="border-bottom:solid 1px #CCC;margin-bottom:10px;padding-bottom:10px;padding-left:5px;min-height:75px;max-height:600px;overflow:auto" class="classe_status" id="'.$resultado_status->fields['TPMps_id'].'">
<div style="width:50px;float:left">'.
'<img src="../perfil_fotos/'.$id.'/perfil/'.$resultado_mostra_foto->fields['TPMpe_foto_perfil'].'" width="50px" height="50px" border="no" align="texttop" />
</div>
<div style="width:400px;margin-left:5px;display:inline-block">
<font style="font-size:16px;color:#06F;font-weight:bold">'.$resultado_mostra_foto->fields['TPMpe_nome'].' '.$resultado_mostra_foto->fields['TPMpe_sobrenome'].' </font>'.$resultado_status->fields['TPMps_tipo'].'
</div>
<div style="padding-left:10px;margin-left:60px;padding-top:5px" class="mensagem_status">'.$resultado_status->fields['TPMps_mensagem'].'
</div>
<div style="text-align:right;display:inline-block;float:right;margin-top:30px;padding-right:5px">'.
$data.'
</div>
</div>';
$resultado_status->MoveNext();
}
if($retorno!="")
{
echo $retorno;
}
}Discussão (8)
Carregando comentários...