title: How to pass json data store in the variable from one page to another page in javascript function?
body: <p>I have stored <code>JSON</code> data response from server into<code>oldJson</code> variable. I want to pass this variable data to new page where another JS function is found.</p>
  
  <p><strong>Here is the first page code</strong>   </p>
  
  <pre><code>$(document).ready(function(){
      $("#submitform").click(function(e)
      {
      var MyForm = JSON.stringify($("#myform").serializeJSON());
      console.log(MyForm);
       $.ajax(
       {
       url : "http://localhost:8080/e-learner/v1/signIn",
       type: "post",
       headers: { 'Content-Type': 'application/json' },
       data : MyForm,
  
      success:function(data,status){
  
         console.log(data);
         if(data.status==1)
         {
         alert(data.errorMessage);//alert ur data here by checking data
         }
         else if(data.clientType == "Admin")
         {
           var oldJson = JSON.stringify(data);
           console.log(oldJson);
  
           $('#temp').data('oldJson', jData);
  
       // alert("Your account created Successfully. Your Reference Key is"+data.referenceKey); 
       window.location.href = "Report.html"
        //redirect code to dashboard page console.log(JSON.stringify(data));
      }
      else
      {
      window.location.href = "index.html"
  }
      },
      error:function(err){
         console.log(err);
         alert(err.statusText);
      }
  
       });
  
  
      });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>Second page code</strong><br>
   <code>$.getJSON('jData', function(jsonData)</code> in this function I want to pass <code>oldJson</code> data variable </p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
  
          jData = $('#temp').data('oldJson');
      $.getJSON('jData', function(jsonData) {
  
  
      console.log(jsonData);
  
      var s1=jsonData.data.student;
  
      for (var i = 0; i &lt; s1.length; i++) {
         var counter = s1[i];
         if(jsonData.status!="error")
              {
                  tr = $('&lt;tr/&gt;');
                  tr.append("&lt;td&gt;" + counter.referencekey + "&lt;/td&gt;");
                 tr.append("&lt;td&gt;" + counter.email + "&lt;/td&gt;");
                  tr.append("&lt;td&gt;" + counter.clients+ "&lt;/td&gt;");
  
                  $('table').append(tr);
  
              }
        else
            {
              alert(jsonData.message);
            }
        }
  
       });
          });
  
  
  
  
      &lt;/script&gt;
  </code></pre>