$(document).ready(function(){ if (typeof String.prototype.trim !== 'function') { String.prototype.trim = function() {return this.replace(/^\s+$/gi, '');} } $("#lang").click(function () { $.ajax({ url: $("#s-patch").text()+"set_lang.php", type: "POST", data: "lang="+$(this).attr("alt"), dataType: "html", timeout: 3000, success: function( return_val ) { location.reload(); } }); }); });