$(".switchlanguage").css("cursor", "pointer") .click(function() { $.post("/php/change_language.php", { lang: $(this).attr("rel") }) .done(function(response) { if (response == "success") {window.location.reload();} else { alert("Sorry, there was an error."); } }); });