I encountered an issue while attempting to call a function in the c# controller and passing a value. The error message I received was: `'Unable to get property 'then' of undefined or null reference'. I also included the Driver Model but still faced this problem. Thank you in advance for any assistance.
JS
function getDrivers(lastName)
{
console.log(lastName);
return $http.post(baseUrl + 'Admin/getDrivers', { lastName: lastName })
.success(function (data, status, headers, config) {
console.log(1);
}).error(function (data, status, header, config) {
console.log(2);
});
}
C# Controller
[HttpPost]
public JsonResult getDrivers(DriverModel model)
{
JsonResult jsonResult = new JsonResult();
try
{
jsonResult.Data = model.GetDrivers(model.lastName);
return jsonResult;
}
catch (Exception ex)
{
return jsonResult;
}
}
HTML
vm.getMatches = function (searchText) {
if (searchText.length > 1)
{
getDrivers(searchText);
}