JSFiddle - React, Tailwind, and code Playground
by viatropos
HTML
<a class='link-with-error' href="http://github.com">Github (Throws Error)</a>
<a class='link-without-error' href="http://github.com">Github (Doesn't Throw Error)</a>
CSS
a {
display: block;
}
JavaScript
function ajaxifyWithError() {
$("a.link-with-error").click(function(event) {
try {
// say the library is the one with this try/catch block
throw new Error("Oops! Some code from some other library through an error!")
event.preventDefault();
return false;
} catch (error) {
alert("I'm changing pages, now I don't have time to inspect Error. Since this is jsFiddle, I'm not actually following the link, but normally it would");
window.location.href = $(this).attr("href");
return true;
}
});
}
function ajaxifyWithoutError() {
$("a.link-without-error").click(function(event) {
event.preventDefault();
return false;
});
}
$(document).ready(function() {
ajaxifyWithError();
ajaxifyWithoutError();
});