ajax401错误,c# - Ajax returning error 401 ("Unauthorized") in jQuery - Stack Overflow

Newbie here. I have an issue about Ajax. The situation is this: I have a multiselect dropdownlist of managements, and I want to bring the managers from those managements, and attach them on another dropdownlist (I did not finish that).

Here, I call the function and send the selected values:

getManagersByManagement($("#ddlManagement").val());

For now, I want this to return the data from GetManagers, on JsonGridDataProvider.svc.

function getManagersByManagement(managementIds) {

$.ajax({

type: "GET",

contentType: "application/json; charset=utf-8",

url: "../../JsonGridDataProvider.svc/GetManagers",

data: { 'Id': JSON.stringify(managementIds) },

dataType: "json",

success: function (data) {

$.jStorage.set($rpt.pageIdentifier + "-Managers", JSON.stringify(data));

alert($.jStorage.get($rpt.pageIdentifier + "-Managers"));

},

error: function (jqXhr, textStatus, errorThrown) {

alert("fail");

}

});

This is the GetManagers function >>

[OperationContract]

[WebGet(ResponseFormat = WebMessageFormat.Json)]

public List GetManagers(long[] managementIds)

{

IList allUserList = (new UserBiz()).GetAllByUserByTypeAndState(2, 3);

List list = (from v in allUserList where v.Active == true orderby v.FullName ascending select v).ToList();

var finalUserList = (from item in list

let sameManList = (from v in item.Management

where managementIds.Contains(v.Id)

select v.Id).Distinct().ToList()

where sameManList.Count > 0

select item).ToList();

return finalUserList;

}

But when instead of going to the GetManagers function, it returns "error 401" ("Unauthorized"). Any idea why is this happening?

EDIT

Thank you all for your replies. Thanks to that, I checked the problem is not the javascript function nor the ajax configuration, but the GetManagers() function (or some configuration I'm missing). Any ideas?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值