I am not able to send session storage data through AJAX to the server
<p>I have stored the ID of the user in session storage. I need to perform an action using the ID so I am passing it to the server using AJAX but the data is not reaching the server.</p>

<p>AJAX:-</p>

<pre><code>$(document).ready(function(){
  $('#coupon_code').hide();
  $('#coupon_status').hide();
  var id = sessionStorage.getItem('user_id');

  $('#generate').click(function(){
    $.ajax({
      type : "POST",
      dataType : 'json',
      url : 'http://127.0.0.1/ionic/generate.php',
      data : id,
      beforeSend : function(){
        console.log(sessionStorage.getItem('user_id'));
        console.log("data sent");
      },
      success : function(data){
        console.log(data);
        console.log(data.code);
        console.log(data.value);
      }
    });
  });
});
</code></pre>

<p>PHP script:-</p>

<pre><code>&lt;?php
require 'db_connect.php';
header('Access-Control-Allow-Origin: *');
$id = $_POST['id'];

$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$string = '';

for ($i = 0; $i &lt; 5; $i++) {
    $string .= $characters[mt_rand(0, strlen($characters) - 1)];
}
$ins = "INSERT INTO `coupon_code` (id,code,status) VALUES ('$id,'$string',1)";
$res_ins = mysqli_query($con,$ins);

if($res_ins)
{
    echo json_encode(array("status" =&gt; "done", "code" =&gt; $string,"value" =&gt; "1"));
    //echo $string;
}
else
{
    echo "NO";
}
?&gt;
</code></pre>

<p>EDIT :-
Firebug result
<a href="https://i.stack.imgur.com/xqkvm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xqkvm.png" alt="enter image description here"></a></p>