title: How to update a php page when a user logs in using AJAX and jQuery?
body: <p>I want to run bellow php page when a user logs in. I'm using bellow php code to show online visits with their name and I also linked their profile page with it. </p>
  
  <p>The php page is running when the <code>online.php</code> is reloading. </p>
  
  <p>It's the normal way of php, I know, but I want to use ajax to run bellow php script. I know how to send form data using ajax, but I don't know how to send data if there aren't any forms inside the page. </p>
  
  <p>How is this possible? I tried it but it's not working yet. <strong>Note</strong>: I'm also using JQuery.  </p>
  
  <p><strong>AJAX code</strong></p>
  
  <pre><code>//update the online users list
  $.ajax({
      type: "POST",
      url: "online.php",
      data: data,
      success: function (response) {
          $("#online").html(response);
      }
  }); //end it
  </code></pre>
  
  <p><strong>PHP code</strong></p>
  
  <pre><code>&lt;?php
      session_start();
  
      include('controller/class/RO_dbconfig.php');
  
      $sth = $dbconnect-&gt;prepare("SELECT first_name,keyId FROM register WHERE status = :online");
      $params = array("online" =&gt; 1);
      $sth-&gt;execute($params);
      $status = $sth-&gt;fetchAll();
  
      echo "&lt;div id='online'&gt;";
  
      foreach($status as $onlineArray) {
          echo "&lt;ul class='online'&gt;";
          echo "&lt;li&gt;&lt;a href='timeline.php?profileId=".$onlineArray['keyId']."'&gt;".$onlineArray['first_name']."&lt;/a&gt;&lt;/li&gt;";
          echo "&lt;/ul&gt;";
      }
  
      echo "&lt;/div&gt;";
  ?&gt;
  </code></pre>