I want to set a cookie value when user clicks on a link. I am using the following code:
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="../../Scripts/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
function changeLang(lang) {
$.cookie('myCulture', lang);
window.location.reload();
return false;
}
});
</script>
HTML
<a href="#" onclick="changeLang('da-DK')"><img src="../../Content/images/danishFlag.png" height="35px" width="35px"/></a>
<a href="#" onclick="changeLang('sv-SE')"><img src="../../Content/images/swedishFlag.png" height="35px" width="35px"/></a>
It looks like very simple code, but when I click on the link, there is an error in the browser. It says.
ReferenceError: changeLang is not defined
changeLang("da-DK");
Where am I doing wrong??