2016-12-02 251 views
1

這裏我; m使用角度與mvc當我; m試圖發送數據我收到錯誤如上所示,我也得到一些腳本errr無法加載資源:服務器響應狀態爲500

$scope.DeleteCustomer = function(list) { 
      var itemList = []; 
      angular.forEach(list, function(value, key) { 
       if (list[key].selected) { 
        itemList.push(list[key].selected); 
       } 
      }); 

      $http.post("/Department/GetEmployeeById/" + itemList).success(function (data) { 
       $window.alert(data); 
      }).error(function(msg) { 
       console.log(msg); 
      }); 
     } 

Htmlcode

<div ng-controller="EmpCtrl"> 
      <input type="button" class="btn btn-sm btn-primary pull-right" ng-model="isAll" value="GetData" ng-click="BtnClick()"> 
    <table class="table table-hover table-bordered" ng-show="GetDb.length>0"> 
       <tr> 
        <th> 
         <input type="checkbox" ng-model="Chk" /> 

        </th> 
        <th>Id</th> 
</tr> 
       <tr ng-repeat="ee in GetDb"> 
        <td><input type="checkbox" id="check1" ng-true-value="{{ee.id}}" ng-false-value="''" ng-model="ee.selected" /></td> 
        <td>{{ee.id}}</td> 
+0

http 500意味着服務器有問題。我會打你的日誌,並找出實現GetEmployeeById方法的代碼中發生了什麼(你的服務器端代碼是用什麼書寫的?)。 另外,如果您遇到腳本錯誤,它是什麼? 我很懷疑你調用GetEmployeeID的方式。您將一個數組追加到URL的末尾,但它是一個POST。你確定這是正確的(它看起來很腥),並且該服務設置爲接收該服務的POSTS? –

+0

您的api只需要一個ID – Sajeetharan

+0

bt sajee bhai我試圖刪除多次rec –

回答

1
return $http.post("/Department/GetEmployeeById/", itemList).success(function (data) { 
      $window.alert(data); 
}).error(function (msg) { 
     console.log(msg); 
}); 

確保已注入$窗口控制器

相關問題