jQuery .get()/.post() doesn't send an updated cookie
Posted
by Markus
on Stack Overflow
See other posts from Stack Overflow
or by Markus
Published on 2010-05-18T19:39:43Z
Indexed on
2010/05/18
19:40 UTC
Read the original article
Hit count: 177
Hello,
I'am doing something like this:
function setCookie(name, value, expire) {
var exdate = new Date();
exdate.setDate(exdate.getDate()+expire);
document.cookie=name+ "=" +escape(value)+((expire==null) ? "" : ";expires="+exdate.toGMTString());
}
// When I click a button
// Update the cookie
setCookie("test", "1");
function getContent() {
// Get the data of our new URL
$.get("index.php", loadContent);
}
function loadContent(data) {
// alert the new title
// the PHP script is changing title after what cookie-value you have
alert($("title", data).text())
}
First of all, when Iam alerting it is still the last showing up. So I guess it doesn't send the changed cookies at all.. And for some reason I don't see the request in my Live HTTP Headers window...
But also, if i request the URL(without the ajax) it works just fine
What am I doing wrong here?
Regards Markus
© Stack Overflow or respective owner