Calling Web Service using Ajax JQuery
Below is Ajax Function Calling Code Behind method for Saving the Data
this 3 StudentId, Date, Status parameter that passing value to code behind
function PopulateData(StudentId, Date, Status) {
var pageUrl = '<%=ResolveUrl("MonthlyAttendence.aspx")%>'
//alert(StudentId + ' , ' + Date);
$.ajax({
type: "POST",
url: pageUrl + '/SaveData',
data: "{ 'StudentID':'" + StudentId + "', Date:'" + Date + "', Status:'" + Status + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnCitiesPopulated,
failure: function (response) {
alert(response.d);
}
});
}
SaveData are Web Method at Code Behide
.cs Page
[WebMethod]
static public string SaveData(string StudentID, string Date, string Status)
{
string[] batch = HttpContext.Current.Session["BatchIds"].ToString().Split(',');
string BatchID;
string[] dt = Date.Split('_');
if (dt[1] == "0") BatchID = batch[0];
else BatchID = dt[1];
Parameter(StudentID, dt[0], Status, BatchID);
return null;
}
Below is Ajax Function Calling Code Behind method for Saving the Data
this 3 StudentId, Date, Status parameter that passing value to code behind
function PopulateData(StudentId, Date, Status) {
var pageUrl = '<%=ResolveUrl("MonthlyAttendence.aspx")%>'
//alert(StudentId + ' , ' + Date);
$.ajax({
type: "POST",
url: pageUrl + '/SaveData',
data: "{ 'StudentID':'" + StudentId + "', Date:'" + Date + "', Status:'" + Status + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnCitiesPopulated,
failure: function (response) {
alert(response.d);
}
});
}
SaveData are Web Method at Code Behide
.cs Page
[WebMethod]
static public string SaveData(string StudentID, string Date, string Status)
{
string[] batch = HttpContext.Current.Session["BatchIds"].ToString().Split(',');
string BatchID;
string[] dt = Date.Split('_');
if (dt[1] == "0") BatchID = batch[0];
else BatchID = dt[1];
Parameter(StudentID, dt[0], Status, BatchID);
return null;
}
No comments:
Post a Comment