I have ajax function as:
function LoadTeacherObservationData(_CategoryID, _SearchText) {
alert("In here");
alert(_CategoryID);
alert(_SearchText);
flag = 1;
$.ajax({
url: "PP/getTeacherObservationData",
data: {
'CategoryID': _CategoryID,
'SearchText': _SearchText
},
dataType: "json",
type: 'POST',
cache:false,
success: function (data) {
OnlebelChange(_CategoryID);
$('#hdnCategoryID').val(_CategoryID);
$("#lvTeacherData").kendoListView({
dataSource: data,
dataBound: function(e) {
if(this.dataSource.data().length == 0){
//custom logic
$("#lvTeacherData").append("<h4> No record found.</h4>");
}},
template: kendo.template($("#lvTeacherData_Template").html())
});
},
error: function () {
alert("error in click");
}
});
}
I have made sure that function is getting called with correct parameters as i have checked it through alert box.
My problem is its not getting rendered to:
PP/getTeacherObservationData as i have mentioned in URL.
PP is my controller and getTeacherObservationData is my function.
I have written that function as follows:
public JsonResult getTeacherObservationData(string CategoryID, string SearchText)
{
try
{
if (CategoryID == "1")
return Json(new TeacherObservation().ScheduledObserVations(SearchText));
if (CategoryID == "2")
return Json(new TeacherObservation().InProcessObservations(SearchText));
if (CategoryID == "3")
return Json(new TeacherObservation().CompletedObservations(SearchText));
return Json(new List<TeacherObservation>());
}
catch (Exception ex)
{
throw ex;
}
}
Instead of calling this function ajax function code goes in error block and gives me alert as: error in click
What can be the problem??
Please help me.
I want to make function call through ajax.
Using MVC4.