I have a html menu with links that load the main content of the page through ajax. The href links in the menu are empty and the content loads with onclick bound functions:
<a href="#" onclick=home_link()>
<i class="icon-home"></i>
<span>Home</span>
</a>
function home_link() {
$.ajax({
url: 'home.html',
dataType: 'html',
cache : false,
success: function(html) {
$('#content_div').append(html);
}
});
I have a few links like that in the menu and it works ok if I click them one by one but if I click another link while one is already loading then unwanted things happen, like various contents go into the <div>.
I would like to disable the onclick globally while the function executes and then reenable it or something equivalent that prevents clicking on other links while one is loading.