我在asp.net下面有控制器动作
[HttpPost]
[Route("ReportProblem")]
public IHttpActionResult ReportProblem(int BusinessID, int RoomID, int RoomFacilityID, int ComponentID, string[] BinImages, string ProblemDesc)
{
return Ok("Thank you for reporting the issue.");
}
现在,我想使用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(
});
答案 0 :(得分: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'
}
});
答案 1 :(得分: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;
});
答案 2 :(得分:0)
您可以尝试这样:
$http.post('/api/room/ReportProblem',
{ BusinessID: 1,RoomID : 1,RoomFacilityID : 1}).success(function (res) { response = res; });