ajax - Jquery Autocomplete Unauthorized Webmethod -
i attempting use jquery autocomplete textbox data database in webform (.net 4.6). when ajax method fired, receiving 401 unauthorized error in console.
please let me know how hit webmethod on serverside useing jquery autocomplete function.
my js file follows:
$(function() { ... $("input[id*='txtdiagnosissearch']").autocomplete({ source: function(request, response) { $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "/webuserprovider/referral_precert_cnreferralform.aspx/getdiagnosiscodes", data: "{'diagcode':'" + $("input[id*='txtdiagnosissearch']").val() + "', 'description':'" + $("input[id*='txtdiagnosissearch']").val() + "'}", datatype: "json", success: function(data) { response(data.d); }, error: function(result) { alert("no match"); } }); } }); }); my html follows:
<asp:content id="content1" contentplaceholderid="contentplaceholder1" runat="server"> <script src="../javascript/webprovider/referral_precert_cnreferralform.js"></script> ... <div style="display: inline-block; font-weight: bold; width: 20%"> <asp:textbox runat="server" id="txtdiagnosissearch"></asp:textbox> </div> ... </asp:content> and server-side code follows:
[webmethod] public list<referral_precertvo.diagnosiscodes> getdiagnosiscodes(string diagcode, string description) { var list = new list<referral_precertvo.diagnosiscodes>(); list = objreferral_precertbl.getdiagnosiscodes(diagcode, description); return list; }
Comments
Post a Comment