Strange cookie bug, javascript
I cannot figure out why this is happening at all. I have a form, and a button that calls a method that uses jQuery to serializes the form and sticks it into a cookie, here:
function serializeFormToCookie(){
var str = $("form").serialize();
alert(str);
document.cookie = str + "&expires=" + expires.toUTCString()
alert("You have successfully stored your reservation, please click show if you would like to review it.")
}
(When I do a quick check and just alert(str) the string is exactly as I expect it.
There is a second button that calls a show method here is the show method:
function showData(){
var savedCookie = document.cookie
var dataArray = savedCookie.split("&")
alert(dataArray[0]) //this is blank! it should be the first key value pair from str!
alert(dataArray[1]) //this is "; key=value" I have NO idea where the ";" is coming from!
alert(datArray[2....etc]) //this is perfect, comes up as key=value.
}
Can anyone figure out what is going on here?
1
Please sign in to leave a comment.
Comments
0 comments