title: Pass variable using AJAX and use it on other page
body: <p>I'm trying to use the value sent by the AJAX request and echo it on a page.
  Here is how I did the AJAX on the first page (account.php):</p>
  
  <blockquote>
    <p>account.php</p>
  </blockquote>
  
  <pre><code>$(document).on('click', 'div#demo', function(){
      var id = $(this).attr('data-id');
      $.ajax({
          url: 'view.php',
          type: 'get',
          data: {id : id},
          success: function(data) {
              console.log(data);
          }
      });
  });
  </code></pre>
  
  <p>Note: From <em>account.php</em> the user is navigated away when she/he clicks on an <em>a href tag</em>. That <em>a href tag</em> actually holds the unique ID what I use to pass to <em>view.php</em> within a div with ID of #ad. Also I'm using Bootstrap that's why I pass <em>data-id = value</em>.</p>
  
  <p>I'm sure the AJAX works perfectly as the Console (F12) shows me that the request has been sent and the value what I used also got passed and the HTML uses it but it does not appear on the actual page so I can only see it in the browser's console. I found similar questions to mine but there were no exact answers to solve the problem.
  The other file looks like this:</p>
  
  <blockquote>
    <p>view.php</p>
  </blockquote>
  
  <pre><code>&lt;?php 
  require_once 'config.php';
  
  $id = $_GET['id'];
  $geturl = $conn-&gt;query("SELECT title, url FROM table1 WHERE id='$id'");
  $url = mysqli_fetch_row($geturl);
  
  $conn-&gt;close();
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;iframe class="embed-responsive-item" src="&lt;?php echo ($url[1]); ?&gt;"&gt;&lt;/iframe&gt;
  
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So I would like to place an unique URL into an <em>iframe</em> after I get the value passed by AJAX and use that variable to do my SQL SELECT statements. After it succeed (because it does as it shows in the Console) I assign the SQL result-set to a variable and use that to give the value of the <em>iframe</em>. But if I click on an <em>a href</em> from <em>account.php</em> I'm navigated to <em>view.php</em> and I see only a blank iframe meanwhile the Console exactly shows that the <em>iframe</em> has the source what I want it to have.</p>
  
  <p>I tried <em>json_encode</em> with the <em>str_replace</em> function but it does not work. I have also tried mixing encode and decode like</p>
  
  <pre><code>$enc = json_encode($row[1]);
  $dec = json_decode($row[1]);
  // and set the iframe src to $dec but still does not work.
  </code></pre>
  
  <p>Thanks for suggestions, appreciate your time!</p>
  
  <p><strong>UPDATE:</strong> I do not want to callback a function from the view.php, so I don't want to set the <em>success: function(response)</em> in AJAX to have a response from the sent request. I only want to use the passed variable on the view.php page, actually to echo it out after I ran my SQL stuff.</p>