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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -