2017-04-06 70 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; });