0

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() });
tereško
  • 58,060
  • 25
  • 98
  • 150
Kavitha P.
  • 155
  • 1
  • 2
  • 13

3 Answers3

1

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

user3755768
  • 67
  • 1
  • 6
0

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.

0

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
}
trailmax
  • 34,305
  • 22
  • 140
  • 234