这是我的javascript:
var summariesApp = angular.module('summariesApp', []);
summariesApp.config(function($httpProvider){
$httpProvider.defaults.headers.get = {};
$httpProvider.defaults.headers.get.ContentType = "application/json; charset=utf-8";
$httpProvider.defaults.headers.post.ContentType = "application/json; charset=utf-8";
});
summariesApp.controller("singleSNPController", function ($scope, $http) {
$scope.summaryId = parseInt($("#SummaryId").value);
var request
if ($scope.summaryId != 0) {
$http.post("SingleSNP30second.aspx/GetSummary",
{ summaryId : $scope.summaryId }
).success(
function (data) {
$scope.summary = data.d;
}
)
}
});
这是我的asp代码:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public static List<tbl_thirty_second_summaries_single_snp> GetSummary(int summaryId)
{
DeveloprodDataClassDataContext masterDb = new DeveloprodDataClassDataContext();
var Summaries = (from s in masterDb.tbl_thirty_second_summaries_single_snps
where s.ThirtySecondSummaryId_this == summaryId
select s).ToList();
return Summaries;
}
$ http服务调用中出现问题。当我尝试$ http.get(没有第二个数据参数)时,我返回了aspx页面的html。看起来服务器不理解我想要的方法。当我尝试$ http.post时,我收到一个错误:
"An attempt was made to call the method \u0027GetSummary\u0027 using a POST request, which is not allowed."
提前感谢。
编辑:这是获取来源:
$http.post("SingleSNP30second.aspx/GetSummary").sucess ...