PHP AJAX MYSQL Post Data is not being recieved -


so i'm trying post/update data in mysql table seems post data not being received. need getting post data output.

users.php

<form id="myform" method="post" action="" >     <input hidden name="identifier" id="identifier" value="<?php echo $identifier; ?>" />     <input type="submit" name="submit" value="update" id="sub" class="btn btn-info pull-right"/> </form> 

actions/users_manage.php

$db = new pdo('mysql:host=127.0.0.1;dbname=db_name', 'db_user', 'db_pass'); $identifier = htmlspecialchars($_post['identifier']);  if(isset($_post['submit'])){     try {     $stmt = $db->prepare("update users set identifier=:identifier identifier=:identifier");     $stmt->execute([':identifier' => $identifier]);     } catch (exception $e) {         echo 'caught exception: ', $e->getmessage(), "\n";     } die(); } 

actions/users_manage.js

$(document).ready(function(){ $('#myform').submit(function(){     var data = $(this).serialize();      $.ajax({         url: "actions/users_manage.php",         type: "post",         data: data,         success: function( data )         {             alert( data );         },         error: function(){             alert('error');         }     });      return false;     }); }); 

when try adding var_dump($_post) users_manage.php above if(isset) displays array(0){}, processing working. it's not receiving post data, please :) appreciated!

when add users_manage.php:

var_dump($_post['identifier']); 

it displays alert "null".

so turns out, needed change var data = $(this).serialize(); var data = $(this).serialize(); manages work.

working ajax:

$(document).ready(function(){ $('#myform').submit(function(){     data = $(this).serialize();     // alert(data);     $.ajax({         url: "actions/users_manage",         type: "post",         data: data,         success :   function(){             alert(data);         },         error   :   function(){             alert('error');         }     });      return false; }); });