how do I read various news, is appearing only the last

Asked

Viewed 23 times

0

//CONEXAO COM O SEVIDOR DO SINDITAC E PEGAR O JSON COM AS NOTICIAS
$.getJSON("http://sinditac.siteseguro.ws/api/news.php?t=d18d31bd9b9f5f7b338e41b5986183a2f3008b541d7c84e442", function(data){
    // LER O JSON E INCLUIR NAS VARIAVEIS 
    for (i = 0; i < data.noticias.length; i++) {

        var  id ='';
        var titulo_breve = '';
        var titulo = '';
        var  noticia = '';
        var  imagem = '';
        var quem_cadastrou = '';
        var dt_cadastro = '';
        var dt_exclusao = '';

        id = data.noticias[i].id;
        titulo_breve = data.noticias[i].titulo_breve;
        titulo = data.noticias[i].titulo;
        noticia = data.noticias[i].noticia;
        imagem = data.noticias[i].imagem;
        quem_cadastrou = data.noticias[i].quem_cadastrou;
        dt_cadastro = data.noticias[i].dt_cadastro;
        dt_exclusao = data.noticias[i].dt_exclusao;


        // POPULAR O BANCO DE DADOS 
        conexao.transaction(function(tx){
            tx.executeSql('insert into noticias(titulo_breve, titulo, noticia, imagem, quem_cadastrou, dt_cadastro, dt_exclusao) values(?,?,?,?,?,?,?)',[titulo_breve, titulo, noticia, imagem, quem_cadastrou, dt_cadastro, dt_exclusao],
            function(tx, res){
                console.log(res);
            });
        });
    }
});
}
  • as it is only appearing one, and in json it has 10 ? in its code displays nothing only inserts in a table

  • appears yes the 10 but with the same information, repeating all news from 1 to 10 with the same information

  • the 10 appears only the last news that was posted on the site

  • I even tried to do a test but as it has Cors enabled not managed so fast

  • If someone can help me, please I need enough..

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.