php - AJAX is temperamental or slow when deleting from database -
php - AJAX is temperamental or slow when deleting from database -
i'm having problem when utilize ajax edit sql database through php. works in effect, have click "remove" button, refresh page see hasn't worked , exact same thing 1 time again works, or wait few seconds before reloading page. seems odd.
this html , js
<html> <script type="text/javascript"> $("#placetable").on('click', 'button.remove', function(e){ var targ = e.target; var id = $(targ).attr('data-id'); bootbox.confirm("are sure want remove?", function(result) { if (result == true) { $.post('/removelocation', {lid : id}, function(){ $(targ).closest('tr').remove(); }) } }) }) </script> <table id="placetable" class="table table-hover table-condensed"> <tr> <th>date</th> <th>place</th> <th>comments</th> <th>actions</th> </tr> {% locat in location %} <tr> <td data-id="{{locat.getid}}">{{locat.date}}<br/>{{locat.time}}</td> <td data-id="{{locat.getid}}">{{locat.name}}</td> <td data-id="{{locat.getid}}">{{locat.description}}</td> <td> <button data-id="{{locat.getid}}" class="remove btn btn-link"><i class="icon-remove"></i></button> <button data-id="{{locat.getid}}" class="edit btn btn-link"><i class="icon-edit"></i></button> </td> </tr> {% endfor %} </table>
× place name comments utilize location close save changes </html>
this php
<?php case 'removelocation' : r::trash(r::load('location', $_post['lid'])); //i have tried trash element , before using ajax when using simple post form both work me; $locationid = $_post['lid']; $locat = r::load('location', $locationid); $usery = r::load('user', $_session['user']->getid()); r::trash($locat); r::dependencies(array('location'=>array('user'))); unset($usery->ownlocation[$locationid]); r::store($usery); exit; ?>
any help in figuring out why not work much appreciated. thanks
php html5 jquery twig redbean
Comments
Post a Comment