【发布时间】:2018-04-12 09:41:57
【问题描述】:
这是我的 WebApi 操作方法:
public List<MemberViewModel> Get(int org)
{
return DataAccess.Member.GetMembers(org);
}
还有,这是 jQuery Ajax 调用方法:
$.ajax({
url: "http://localhost:800/api/Members?org=10",
type: 'GET',
contentType: 'application/json; charset=utf-8',
success: function (results) {
alert('worked');
}
});
当我在firebug中检查“Net”选项卡时,可以看到结果为XML的请求,但状态中有“405 Method Not Allowed”错误,因此不会调用成功方法。
我从上面的 js 代码中删除了“contentType”属性,它运行良好但请求的结果为空。
【问题讨论】: