javascript - jQuery function $.post with .remove -


trying build simple jquery allows user click button within table row should run separate php script delete item db row , remove table row in 1 action. (will migrate prepared statements once working.)

html

<tr id="wish_list_row2">   <td class="text-center">     <a href="#" data-toggle="tooltip" data-placement="bottom" title="click download resource" style="margin-right:15px;"><i class="fa fa-download"></i></a>     <a onclick="deletewishlist(3,1)" data-toggle="tooltip" data-placement="bottom" title="click remove resource wish list"><i class="fa fa-gift"></i></a>     </td> </tr> <tr id="wish_list_row3">   <td class="text-center">     <a href="#" data-toggle="tooltip" data-placement="bottom" title="click download resource" style="margin-right:15px;"><i class="fa fa-download"></i></a>     <a onclick="deletewishlist(4,1)" data-toggle="tooltip" data-placement="bottom" title="click remove resource wish list"><i class="fa fa-gift"></i></a>   </td> </tr> 

js

function deletelike(rid,uid) {     $.post("remove_this_item.php?rid="+rid+"&uid="+uid);     $('#row'+rid).remove();     return false; } 

php

include_once ('[include mysql connection variables - removed demo]');  $rid = $_get['rid']; $uid = $_get['uid'];  // create connection $conn = mysqli_connect($servername, $username, $password, $dbname);  // delete 'like' db user $sql = "delete likes user_id_ref='$uid' , resource_id_ref='$rid' limit 1";  $conn->query($sql);  mysqli_close($conn); 

when click 'remove' link, tr removed expected. however, db row remains intact. if manually set rid , uid on php page in url, db row delete. i've tried altering few things (such rid , uid order), haven't had success yet.

i not ultra familiar js yet, maybe screwed in writing function?

you doing $.post in php script trying retrieve $_get[]. change $_post[] , should work fine.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -