I would like to create a landing page consisting only of links. The links should make a post request to a server side script which will set some cookies and redirect the browser to another page. The reason for doing this is that I am bolting on a new locale selection page to an existing site which already has the locale logic built in - it sets a cookie containing a 2 char locale string.
Jquery is available on my page so I was considering using $.post() but this only makes XHR requests. Is it possible to do what I want using jquery? Or do I need my 'links' to be buttons within a form?
The following code makes an XHR request
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="/_scripts/jquery-1.6.1.min.js"></script>
</head>
<body>
<a id="test" href="">link</a>
<script type="text/javascript">
$(function(){
$('#test').bind('click', function(){
$.post('/select-locale/processing',
{'locale':'NZ',
'returnPage':'/'
});
});
})
</script>
</body>
</html>
I guess I can just return a boolean value from my php script and then do window.location.href on success but wondered if there was an alternative.