Reputation: 155
i have my jquery like,
$('#SearchFor').button().click(function () {
var SearchForValue = $("#NotAllotedStudentsList").val();
var StudentInputTypeValue = $("#InputType").val();
alert(StudentInputTypeValue);
var options = {};
options.type = "POST";
options.url = "/Dashboard/NotAllotedStudentsList/";
options.data = JSON.stringify({ model: { SearchFor: SearchForValue, StudentInputType: StudentInputTypeValue } });
options.dataType = "json";
options.contentType = "application/json";
$.ajax(options);
success:handleData;
});
});
i dont know how to use this success(result,status,xhr) for my code, kindly tell me how to handle this successhandler. i have my return type in controller like,
return Json(new { Result = "OK", Records = tutorStudentsGridModelList, TotalRecordCount = studentListResponse.StudentList.Count() });
Upvotes: 0
Views: 179
Reputation: 21
in Options add following line and make sure that handleData function should have parameters. options.success= handleData; Remove success:handleData; from above code
Handle data function should be like:
function handleData(data,status,xhr){
//you can access data from data object like=> data.Result
}
Upvotes: 0
Reputation: 67
hai how about this one ?
$('#SearchFor').button().click(function () {
var SearchForValue = $("#NotAllotedStudentsList").val();
var StudentInputTypeValue = $("#InputType").val();
alert(StudentInputTypeValue);
var options = {
url : "/Dashboard/NotAllotedStudentsList/",
type : "POST",
data : JSON.stringify({ model: { SearchFor: SearchForValue, StudentInputType: StudentInputTypeValue } }),
dataType : "json",
contentType : "application/json"
};
$.ajax(options)
.done( function(response, status, xhr) {
console.log(response);
});
});
});
in my opinion its more readable recommend using function done() rather than success option
Upvotes: 1
Reputation: 21
if you are trying for ajax success add the success to the options like options.success=handleData , the handleData function will be called on ajax success.
Upvotes: 0