Hello everyone,
I am calling a server side method using jQuery and Ajax but getting an "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". I am unable to figure it out kindly, help me correcting out.
Any suggestions will be appriciated below is my code.
<script src="../bootstrap/jQuery/jquery-3.3.1.js" type="text/javascript"></script>
<script src="../bootstrap/jQuery/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#btnSubmit').click(function () {
$.ajax({
url: 'RTGS_FileUpload.aspx/send',
method: 'post',
contentType: 'application/json',
data: '{}',
dataType: "json",
success: function (data) {
alert(data.d.Session["OTP"]);
},
error: function (error) {
alert('error');
}
});
});
});
</script>
[WebMethod]
public static void SendOTP()
{
RTGSFileUpload rfu = new RTGSFileUpload();
BELAP getAgencyBel = new BELAP();
getAgencyBel.ImplementingAgency = Convert.ToInt16(rfu.Session["Agency_Id"]);
BALAP getContactBal = new BALAP();
getAgencyBel.ContactNo = getContactBal.getAgencyContactDetails(getAgencyBel).ToString();
BELSMS objEntity = new BELSMS();
objEntity.Mobile = "+91" + getAgencyBel.ContactNo;
if (objEntity.Mobile != null)
{
rfu.lblContact.Text = "Please enter OTP Send on XXXXXX" + objEntity.Mobile.Substring(objEntity.Mobile.Length - 4);
BALSMS objSet = new BALSMS();
rfu.Session["OTP"] = objSet.SendOtp(objEntity);
}
else
{
rfu.lblContact.Text = "Please contact system administrator";
}
}