I am new to jQuery. Is there any way to retrieve the value of booked
in another page through jQuery?
$(document).ready(function() {
$(".active").click(function() {
var booked=$(this).val();
confirm(booked);
});
});
Use cookies or HTML5 localStorage
if its purely on the client-side.
localStorage.setItem('bookedStatus' + customerId, true);
Else use ajax if the data has already been submitted to server.
$.get('/site/getBookingStatus?customerId=' + customerId, function(data){
alert(data);
});
Alternatively, if this is a simple string you can append with the URL of the page while navigating to another page. If this is secured data, you can encrypt the string and attach.
Your URL will be : example.com/nextPage?x=booked
In the next page you can get the string by decoding it as given :
var encodedData = window.location.href.split('=')[1];
var bookedValue = decodeURI(encodedData);
If you have encrypted the script, you have to decrypt in the next page.
localStorage doesn't work well on mobile browsers. I've given up on trying to get localStorage to work on iPhone/safari. If you're not passing too much data then a simple solution is to attach the data to the url you are navigating to, using the usual ?param= syntax:
// set your data in the source page
function set_url_data(go_to_url, data) {
new_url = go_to_url + '?data=' + data;
window.location.href = new_url;
}
// parse your data in the destination page
function grab_data_from_url() {
url = window.location.href;
data = url.split('data=').pop();
return(data)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With