Ajax方法没有调用web方法。当我在浏览器中检查它显示错误数据=对象{消息:“身份验证失败。”,StackTrace:null,ExceptionType:“System.InvalidOperationException”}如何解决,我也尝试更改Route.config设置.AutoRedirectMode = RedirectMode.Permanent;到settings.AutoRedirectMode = RedirectMode.Off;但它没有解决。
$(document).on("click", ".editButton", function () {
$("#myModal").focus();
var id = $(this).attr("data-id");
debugger;
console.log(id);
$("#btnUpdate").attr("edit-id", id);
$.ajax({
type: "Post",
contentType: "application/json; charset=utf-8",
url: '<%= ResolveUrl("CustTableView.aspx/EditData") %>',
data:JSON.stringify({ eid: "" + id + "" }),
dataType: "json",
success: function (data) {
var empDetails = $.parseJSON(data.d);
$.each(empDetails, function (index, value) {
debugger;
$("#CustomerCode").val(value.Code);
$("#CustomerName").val(value.Name);
$("#MailingName").val(value.MName);
$("#RegOfficeAddress").val(value.Address1);
$("#RegOfficeAddress1").val(value.Address2);
$("#RegOfficeAddress2").val(value.Address3);
$("#City").val(value.City);
$("#StateDropdown").val(value.State);
$("#CountryDropdown").val(value.Country);
$("#Address2-1").val(value.M2Address1);
$("#Address2-2").val(value.M2Address2);
$("#Address2-3").val(value.M2Address3);
$("#City2").val(value.M2City);
$("#StateAddress2").val(value.M2State);
$("#CountryAddress2").val(value.M2Country);
$("#Address3-1").val(value.M3Address1);
$("#Address3-2").val(value.M3Address2);
$("#Address3-3").val(value.M3Address3);
$("#City3").val(value.M3City);
$("#StateAddress3").val(value.M3State);
$("#CountryAddress3").val(value.M3Country);
$("#EmailAcc").val(value.Email);
$("#EmailDSR").val(value.Email1);
$("#ContPer").val(value.Contact);
$("#Telephone").val(value.TelNo1);
$("#FaxNo").val(value.TelNo2);
$("#MobileNo").val(value.TelNo3);
$("#StdCode").val(value.STDCode);
$("#ISDCODE").val(value.ISDCode);
$("#PanNO").val(value.PANNo);
$("#STNO").val(value.STNo);
$("#CSTTIN").val(value.CSTNo);
$("#VATTIN").val(value.VATNO);
$("#CINNO").val(value.TINNo);
$("#LedName").val(value.TallyLedger);
$("#TallyGroup").val(value.TallyGroup);
$("#CustomClearanceCheck").val(value.Contract1);
$("#PhotographCheck").val(value.Photo);
$("#PalletisationCheck").val(value.Pallet);
$("#FumigationCheck").val(value.Fumigation);
$("#LashingCheck").val(value.Lashing);
$("#WarehousingCheck").val(value.WareHouse);
$("#OriginCheck").val(value.Certificate);
$("#SurveyCheck").val(value.Survey);
$("#InsuranceCheck").val(value.Insurance);
$("#TramsportationCheck").val(value.Transport);
$("#ADCCheck").val(value.ADC);
$("#LandingCheck").val(value.IsLC);
$("#SICUTOFF").val(value.SICUTOFF);
$("#ActiveExport").val(value.DSRMail);
$("#ActiveImport").val(value.DSRMail1);
//$("#EstimateCost").val(value.);
$("#ActiveExporyAgent").val(value.AgentMail1);
$("#ActiveImportAgent").val(value.AgentMail2);
debugger;
getDetails();
//alert("hi");
});
},
error: function () {
debugger;
alert("Error while retrieving data of :" + id);
}
});
})
[WebMethod]
public static string EditData(string eid)
{
string jsondata;
using(var scon=new SqlConnection(strConnection))
{
var query = "select Code,Name,MName,Address1,Address2,Address3,City,State,Country,M2Address1,M2Address2,M2Address3,M2City,M2State,M2Country,M3Address1,M3Address2,M3Address3,M3City,M3State,M3Country,TelNo1,TelNo2,TelNo3,Email,Email1,Contact,STDCode,ISDCode,PANNo,STNo,CSTNo,VATNO,TINNo,TallyLedger,TallyGroup,Contract1,Photo,Pallet,Fumigation,Lashing,WareHouse,Certificate,Survey,Insurance,Transport,ADC,IsLC,SICUTOFF,DSRMail,DSRMail1,AgentMail1,AgentMail2 from PartyLedger where Code='" + eid +"' ";
using(var cmd=new SqlCommand(query,scon))
{
using(var sda=new SqlDataAdapter())
{
cmd.Connection = scon;
sda.SelectCommand = cmd;
TableData.Clear();
sda.Fill(TableData);
jsondata = JsonConvert.SerializeObject(TableData).ToString();
}
}
}
return jsondata.ToString();
}