JSFiddle - React, Tailwind, and code Playground
by vfportero
HTML
<a href="#" id='tab'>abre nuevo tab</a>
<br/>
<a href="#" id='no-tab'>es bloqueado</a>
JavaScript
$('#tab').click(function () {
peticionAjax(false);
});
$('#no-tab').click(function () {
peticionAjax(true);
});
function peticionAjax(esUnaPeticionAsincrona) {
// postserver.com es una web para hacer POST en pruebas. Siempre devuelve un 200
$.ajax({
type: "POST",
url: "http://posttestserver.com/post.php",
success: callback,
async: esUnaPeticionAsincrona,
});
};
var callback = function (respuesta) {
window.open("http://www.todoexpertos.com");
};