﻿var active = true;
$(document).ready(function () {
	getJoke();
	$('#newJoke').click(function (a) {
		getJoke();
		return false;
	});
});

function getJoke() {
	if (active) {
		JokeAjax('/Joke/GetJoke', '#currentJoke');
		active = false;
	}
}

function JokeAjax(url, target) {
	$.ajax({
		url: url + '?' + Math.random() * Math.random(),
		cache: 'false',
		success: function (data) {
			$(target).html(data);
			active = true;
		}
	});
}

