Reputation: 278
Good day,
I would just like to know if there is a way of sending localStorage variables through the Ajax function without it being in the url. For example:
$.ajax({
type: "POST",
url: "../pages/profile.php",
data: localStorage.email,
dataType: 'json'
success: function(result)
{
//document.location.replace('../pages/main.php');
},
error: function()
{
alert('An Error has occured, please try again.');
}
});
The return type from the php will be JSON in this case, as needed.
Thanks in advance
Upvotes: 0
Views: 1504
Reputation: 4736
change
data: localStorage.email,
to
data: {email: localStorage.getItem('email')}
So that the data
is in proper JSON format, and using (I believe) the correct way to retrieve an item from localStorage
.
Upvotes: 1