javascript - Ajax jQuery MySql Delete field -


i have fields of phone numbers pulled database through ajax , i'm trying add delete button next info here have far seems should working not. i'm using bootstrap.

html code:

<input type="hidden" value="<?php echo _e($_session['id']); ?>" id="userid"> <div class="row">     <div class="col-md-4">         <p>',_e($r->label),'</p>     </div>     <div class="col-md-6">         <p>',_e($r->phone),'</p>     </div>     <div class="col-md-2">         <a class="delphone" rel="',_e($r->id),'" href="#">             delete number         </a>     </div> </div> 

ajax code

$('.delphone').on('click', function() {     $id = $('#userid').val();     $.ajax({         type: 'post',         url: "functions.php",         data: {"userid":$id, "phoneid": $(this).attr('rel')},          success: function(data) {             console.log(data);         }     });      }); 

php code

if(isset($_post['phoneid']) === true && isset($_post['userid']) === true) {     if(empty($_post['phoneid']) === false && empty($_post['userid']) === false) {         $phoneid    = $_post['phoneid'];         $userid     = $_post['userid'];         require_once 'connect.php';         $sql = "delete numbers userid=:userid , id=:phoneid";         $query = $handler->prepare($sql);         $query->execute(array(             ':userid'   => $userid,             ':phoneid'  => $phoneid         ));     } } 

solution:

the problem not specifying value of $id in ajax why php doesn't know delete.

error message: uncaught referenceerror: $id not defined


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -