c# - Ajax returning error 401 ("Unauthorized") in jQuery -
newbie here. have issue ajax. situation this: have multiselect dropdownlist of managements, , want bring managers managements, , attach them on dropdownlist (i did not finish that). here, call function , send selected values:
getmanagersbymanagement($("#ddlmanagement").val());
for now, want return data 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 getmanagers function >>
[operationcontract] [webget(responseformat = webmessageformat.json)] public list<user> getmanagers(long[] managementids) { ilist<user> alluserlist = (new userbiz()).getallbyuserbytypeandstate(2, 3); list<user> list = (from v in alluserlist v.active == true orderby v.fullname ascending select v).tolist(); var finaluserlist = (from item in list let samemanlist = (from v in item.management managementids.contains(v.id) select v.id).distinct().tolist() samemanlist.count > 0 select item).tolist(); return finaluserlist; }
but when instead of going getmanagers function, returns "error 401" ("unauthorized"). idea why happening?
edit
thank replies. that, checked the problem not javascript function nor ajax configuration, the getmanagers()
function (or configuration i'm missing). ideas?
try adding [httppost] attribute method calling. , change type: "get" type: "post" in script. maybe help. worked me.
Comments
Post a Comment