【发布时间】:2015-09-25 08:29:31
【问题描述】:
当我将 $sce 用于IFrame,但现在我想在应用程序中从 jquery ajax 调用 Web Api。
当我尝试调用它时,我得到了
401 未经授权
function getComments() {
$.ajax({
url: 'http://localhost:17308/Home/GetNewsComments?id=' + group,
type: 'Get',
data: { id: tipId },
success: function (data) {
$("#commentDetail").empty().append(data);
},
error: function () {
//alert("something seems wrong");
console.log("something is wrong");
}
});
};
仅供参考/顺便说一句
我已经能够使用 IFrame 调用
$scope.setTipId = function (id) {
$scope.detailFrame = $sce.trustAsResourceUrl("http://localhost:17308/Home/GetNewsComments?id=" + id);
我可以对来自控制器的 jquery ajax 调用做类似的事情吗?
更新
我什至尝试过“角度方式”
$http.get('http://localhost:17308/CommentCount/').success(function (data) {
console.log('made it');
})
.error(function () {
console.log('error');
});
我仍然收到 401 错误...
【问题讨论】:
标签: javascript jquery ajax angularjs asp.net-web-api