JSFiddle - React, Tailwind, and code Playground

by Leandro Amorim

HTML

<p>Ajax de forma sĂ­ncrona.</p>
<button id="teste">Clique aqui</button>

JavaScript

$(function () {
    
    function buscando_dados() {
        $.ajaxSetup({async: false});
        $.post('/echo/html/', { html: 'teste' }, function (dados) {
            alert(dados);
        });
        $.ajaxSetup({async: true});
    }

    function buscar_dados() {
        buscando_dados();
        alert('prosseguindo');
    }
    
    $("#teste").on('click', function() { buscar_dados(); });
});