MediaWiki:Timeless.js: mudanças entre as edições

De RubinOT Wiki
Sem resumo de edição
Sem resumo de edição
Linha 1: Linha 1:
// Função para fazer fetch dos dados
mw.loader.using('jquery', function() {
mw.loader.using('jquery', function() {
     $(document).ready(fetchData);
     $(document).ready(function() {
        console.log('Document is ready, calling fetchData...');
        fetchData();
    });
});
});


function fetchData() {
function fetchData() {
    console.log('fetchData function called');
     var url = 'https://rubinot.com.br/webservices/worlds.php';
     var url = 'https://rubinot.com.br/webservices/worlds.php';


     fetch(url)
     $.ajax({
        .then(response => {
        url: url,
            if (!response.ok) {
        method: 'GET',
                throw new Error('Network response was not ok ' + response.statusText);
        dataType: 'json',
            }
         success: function(data) {
            return response.json();
         })
        .then(data => {
             console.log(data); // Exibe o conteúdo no console
             console.log(data); // Exibe o conteúdo no console
         })
         },
         .catch(error => {
         error: function(jqXHR, textStatus, errorThrown) {
             console.error('There has been a problem with your fetch operation:', error);
             console.error('There has been a problem with your fetch operation:', textStatus, errorThrown);
         });
         }
    });
}
}
// Chamar a função quando o documento estiver pronto
$(document).ready(fetchData);

Edição das 17h30min de 17 de maio de 2024

mw.loader.using('jquery', function() {
    $(document).ready(function() {
        console.log('Document is ready, calling fetchData...');
        fetchData();
    });
});

function fetchData() {
    console.log('fetchData function called');
    var url = 'https://rubinot.com.br/webservices/worlds.php';

    $.ajax({
        url: url,
        method: 'GET',
        dataType: 'json',
        success: function(data) {
            console.log(data); // Exibe o conteúdo no console
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.error('There has been a problem with your fetch operation:', textStatus, errorThrown);
        }
    });
}