If the two pages are on the same domain, a third way is to use HTML5 localStorage: http://diveintohtml5.info/storage.html

In fact localStorage is precisely intended for what you want. Dealing with GET params or window/document JS references is not very portable (even if, I know, all browsers do not support localStorage).

Answer from Ulflander on Stack Overflow
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 33910409 โ€บ pass-json-object-to-another-page
Pass JSON Object to another page - javascript
Well, if you want to pass some data across pages the best approach would be to use localStorage/sessionStorage (the only difference is that localStorage has no expiration date, sessionStorage is self-describable). var jsonContact = [{"name" ...
Discussions

How do I pass a portion of Json object to another page?
๐ŸŒ forum.jquery.com
How do you pass json data from one page to another to reference the same row of data?
I am pulling address location information from a google spreadsheet and using it to create buttons. When you click on a button it then should open and populate the data for that location in a new ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
jquery - How to pass json data store in the variable from one page to another page in javascript function? - Stack Overflow
I have stored JSON data response from server intooldJson variable. I want to pass this variable data to new page where another JS function is found. Here is the first page code $(document).ready( More on stackoverflow.com
๐ŸŒ stackoverflow.com
February 28, 2017
php - How to pass json data from one html page to other html page using javascript? - Stack Overflow
I have to pass Json data which is generated after inserting the info into datbase table, Now I have to pass this info to other page BookingConformation.html. For example we will get the form serv... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 18, 2017
๐ŸŒ
findnerd
findnerd.com โ€บ list โ€บ view โ€บ Sending-JSON-data-from-one-HTML-page-to-another-using-Session โ€บ 19350
Sending JSON data from one HTML page to another using Session
May 6, 2016 - Here is the code of the send.html file: send this is the jquery code when user clicks the button. $("button").click(function(){ var data = html2json(); storeuserdatainsession(data); window.location = 'slider.html'; });data variable contains the string value that is return by the html2json() function.here is the functionality of thehtml2json() function for getting the text from the input boxes and creating a json string.function html2json() {var key=['terms','definitions'] ;var c =0; var json = '{"userdata":['; var otarr = []; var tbl2 = $('#ul-list li').each(function(i) { x = $(this).find('.in
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 22023844 โ€บ how-do-you-pass-json-data-from-one-page-to-another-to-reference-the-same-row-of
How do you pass json data from one page to another to reference the same row of data?
When you click on a button it then should open and populate the data for that location in a new page or if need into a dialog box. How do you pass the information to a new page and complete the if statement? Everything works great if I manually add the entry.id.$t string in the last if statement. $(document).ready(function () { $(function FISLocations() { $.getJSON("https://spreadsheets.google.com/feeds/list/GoogleSpreadsheetKey/od6/public/values? alt=json-in-script&callback=?", function (data) { $('.loc').append('<ul class="collapsibleList" id="list"><li><label for="mylist-node1" class="css_b
Find elsewhere
Top answer
1 of 3
1

If this is your real server side code then...its completely insecure. You should never pass variables posted by users directly into your queries.

$query2 = "insert into booking(cust_email, cust_mobile, cust_name) values('$mail','$mobile','$name')";  

At least escape the values using "mysql_real_escape_string", or use prepared statements. And...dont use mysql anymore, use mysqli, which is almost identical to what you are using, but not deprecated soon.

Also, you are json encoding a string that doesnt need to be json encoded, its just a piece of text and not valid json code. This may be why @SimarjeetSingh Panghlia answer doesnt work for you.

instead of json_encoding that value, encode a structured array.

$response = array( "status" => true );

if(isset($_POST['type']))
    {
        if($_POST['type']=="booking"){
            $name = mysql_real_escape_string( $_POST ['Name'] ));    
            $mobile = mysql_real_escape_string($_POST ['Mob_Num']);
            $mail = mysql_real_escape_string($_POST ['Email']);               
            $query1 = "insert into customer(userName, userContactNumber, email) values('$name','$mobile','$mail')";
            $query2 = "insert into booking(cust_email, cust_mobile, cust_name) values('$mail','$mobile','$name')";          

            $result1 = mysql_query($query1);          
            $result2 = mysql_query($query2);
            $id = mysql_insert_id();

            $response["message"] = "Welcome Mr/Mrs ".$name."  Thanks for booking home services your booking id is =  ".$id;/* make sure you strip tags etc to prevent xss attack */

        }
    }
    else{
        $response["status"] = false;
        $response["message"] = "Invalid format";
    }

    echo json_encode($response);

    /* Note that you are making the query using ContentType:"application/json", */

which means you should respond using json regardless if query is successful or not. I would also recommend using a simple jQuery plugin called jStorage, that allows easy get/set of objects without having to serialize them.

2 of 3
0

You can use sessionStorage to store and retrieve JSON Data.

var complexdata = [1, 2, 3, 4, 5, 6];

// store array data to the session storage
sessionStorage.setItem("list_data_key",  JSON.stringify(complexdata));

//Use JSON to retrieve the stored data and convert it 
var storedData = sessionStorage.getItem("complexdata");
if (storedData) {
  complexdata = JSON.parse(storedData);
}

To remove sessionStorage Datas after using use sessionStorage.clear();

๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 41692239 โ€บ how-to-pass-json-data-into-query-string-and-use-that-data-in-another-page
how to pass json data into query string and use that data in another page
Here table contains book details which contains book name, author, pric, ISBN and category. When user click on Book Name it should pass the data to another page using querystring
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 33910409 โ€บ pass-json-object-to-another-page
Pass JSON Object to another page
November 25, 2015 - Well, if you want to pass some data across pages the best approach would be to use localStorage/sessionStorage (the only difference is that localStorage has no expiration date, sessionStorage is self-describable). var jsonContact = [{"name" ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 55006320 โ€บ how-to-pass-json-array-of-one-page-into-another-in-php
How to pass json array of one page into another in php?
March 5, 2019 - You could always take it one step further and save the json into a database and access it on the next page then delete it from the database on the bottom of that page. Its clean and efficient.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 67521803 โ€บ use-data-from-json-to-go-to-page
Use data from Json to go to page
function click1() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var Link = JSON.parse(this.responseText); document.getElementById("Link1").innerHTML = Link.title; window.location.href = Link.link; } }; xmlhttp.open("GET", "link.json", true); xmlhttp.send(); } Note that setting the innerHTML of an element before window.location.href = Link.link; is somewhat pointless because updating window.location will cause a new page to load.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 43587968 โ€บ send-json-data-from-one-page-and-receive-dynamically-from-another-page-using-aja
Send JSON data from one page and receive dynamically from another page using AJAX when both page are open
June 8, 2017 - 0 php - Send data from one php page to another and refresh it with the new data ยท 2 How to get data from one php page using ajax and pass it to another php page using ajax
๐ŸŒ
Ionic Framework
forum.ionicframework.com โ€บ ionic framework โ€บ ionic-v3
Passing Json Data to Second Page for Audio player - ionic-v3 - Ionic Forum
June 8, 2017 - Hi , Please can someone help me with this implementation of Media Player fetching from Remote Json. I'm using this Remote data to list Artist, Image but want to pass Audio URL to Player page. Any suggestion on how to impโ€ฆ
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 14637559 โ€บ pass-json-values-across-pages
pass json values across pages
I have defined a json object as function getPost() { var fname = document.getElementById("fname").value; var lname = document.getElementById("lname").value; var v = { ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 62136879 โ€บ how-to-get-json-data-in-one-another-page
How to Get json data in one another page?
June 1, 2020 - Since you already told me above that you have a data.json all you need is to get the user id from the URL and then filter the parsed json like so: