title: Update data record onBlur
body: <p>I am trying to update a record in a database onBlur but it does not work. Any ideas on how I can achieve this? my code looks like below.</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$(function () {
  $("textarea").blur(function() {
  
         var meta_value =   $(this).val();
                  var meta_key   =   $(this).attr("id");
  
               alert(meta_value + meta_key);
  
  
      $.get('script-url', { key: meta_Key, value: meta_value}, function(data) {
  
      });
  });
  });
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  
  
  if(isset($_POST['key']))
  {
     $meta_value = $_REQUEST['value'];
     $meta_key = $_REQUEST['key'];
  
  
  $servername = "hhh";
  $username = "hhh";
  $password = "hhh";
  $dbname = "hhh";
  
  
   global $wpdb;
   $user_ID = get_current_user_id();  
  
  
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  
  
  $sql = "UPDATE wp_usermeta SET meta_value = $meta_value WHERE meta_key = $meta_key AND user_id= $user_ID";
  
  if ($conn-&gt;query($sql) === TRUE) {
      echo "Record updated successfully";
  } else {
      echo "Error updating record: " . $conn-&gt;error;
  }
  
  
  }
  ?&gt;
  </code></pre>