title: angularjs delete through php
body: <p>I am trying to implement delete functionality in angularjs using php as follows:
  delete:
  index.html view:</p>
  
  <pre><code>&lt;ul&gt;
              &lt;li ng-repeat="r in result"&gt;
              {{r.description}}|{{r.name}} | &lt;a href='' ng-click = "edit(r.product_id)"&gt;edit&lt;/a&gt; | &lt;a href='' ng-click = "delete(r.product_id)"&gt;delete&lt;/a&gt;
              &lt;input type="hidden" name="hdnid" ng-model="hdn" value="{{r.product_id}}"/&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
  </code></pre>
  
  <p>in controller:
  delete:</p>
  
  <pre><code>//delete
          $scope.delete = function() {
              var elem = angular.element($element);
              var dt = $(elem).serialize();
              //alert($element);
              console.log($(elem).serialize());
              $http({
                  method: 'POST',
                  url: 'php/delete.php',
                  data: dt,
                  headers: {'Content-Type': 'application/x-www-form-urlencoded'}
              }).success(function(data, status) {
                  $scope.status = status;
                  $scope.data = data;
                  $scope.rs = data; // Show result from server in our &lt;pre&gt;&lt;/pre&gt; element
              }).error(function(data, status) {
                  $scope.data = data || "Request failed";
                  $scope.status = status;
              });
          };
  </code></pre>
  
  <p>and in php file: delete.php</p>
  
  <pre><code>    &lt;?php
  include 'connect.php';
  mysql_select_db($database,$con);  
  $id = $_POST['hdnid'];
  $query = "delete from `product` where `product_id` = $id";
  $result = mysql_query($query) OR die(mysql_error()); 
  echo "You have successfully deleted ";
  ?&gt;
  </code></pre>
  
  <p>The record gets deleted but the page is not refreshed. I cant see the record deleted until I refresh the page.
  Where am I going wrong? how do I refresh the page?</p>