2017-04-06 71 views
0

下面我有在asp.net

現在,我想用angularjs如下張貼控制器動作。但它不起作用。

$http.post('/api/room/ReportProblem?BusinessID=1' + 
'&RoomID=1'+ 
'&RoomFacilityID=1' + 
'&ComponentID=1' + 
'&BinImages=null' + 
'&ProblemDesc=eee', 
{ 
    headers: {'Content-Type': 'application/x-www-form-urlencoded' 
} 
) 
.success(function (response) { 
    console.log(
}); 
+1

「它不工作」 是不夠具體。在瀏覽器中調出F12開發人員工具,單擊網絡選項卡,然後觀看正在進行的調用(如果有)。服務器返回什麼內容? –

+0

請具體說明您收到哪個http狀態碼 –

回答

1

你可以試試這個:

var ReportProblemObject = {BusinessID: 1, RoomID: 1, RoomFacilityID: 1, ComponentID: 1, BinImages: null, ProblemDesc: 'eee'}; 

var payLoad = $httpParamSerializerJQLike(ReportProblemObject); 
$http.post('/api/room/ReportProblem', payLoad, { 
       headers: { 
        'Content-Type': 'application/x-www-form-urlencoded' 
       } 
      }); 
+0

感謝您的回答。我有更多問題。我想發送binImages base64圖像作爲字符數組。我怎樣才能做到這一點? –

+0

有什麼問題? – kaushlendras

+0

發送數組與發送其他參數相同。 – kaushlendras

0
var app = angular.module("myApp", []); 

    app.controller("mycontroller", ['$scope','$http', function($scope, $http) 
      {  

       $http.post('js/data.json').success (function(data){ 
        //alert(JSON.stringify(data.orders)); 
        $scope.jsondata = data; 
       }); 
+0

請停止添加廣告鏈接到您的答案。 – str

0

你可以嘗試這樣的:

$http.post('/api/room/ReportProblem', 
{ BusinessID: 1,RoomID : 1,RoomFacilityID : 1}).success(function (res) { response = res; });