• User Attivo •

    Chiamata ajax di avvia due volte

    Salve, ho un problema con una chiamata ajax, in pratica mi restituisce due volte lo stesso risultato. Vi poso il codice che utilizzo:

    
    function MainNews() {
    
    
        $.ajax({
            type: 'POST',
            url: "xxx.sito.net/news.php",
            dataType: 'json',
            success: function(data) {
    
    
                $.each(data, function(key, value) {
                    $('#text_news').html(value.text_news);
                }); //end .each
            }
        });
    } // Fine MainNews()
    
    
    

    mentre questo è il file php:

    
    $sql = "SELECT * FROM news ORDER BY id DESC LIMIT 1";
    
    
    
    
        $res = mysql_query($sql);
    
    
        $data = array();
    
    
        while ($rows = mysql_fetch_array($res, MYSQL_ASSOC)) {
            $data[] = $rows;
        }
    
    
        echo json_encode($data);
    
    

    Sapete dirmi dove sbaglio?