I have a problem. In my company I need to try out how Angular.js works together with ASP.NET MVC. Now I want to create a simple little application. On the front page there is a view with a Kendo UI grid. Inside my App.js
file I read data from my Data
Controller. The Controller Action gets called but as soon as the code is done executing I get the following error:
Here is the rest of my Code:
Controller:
[HttpGet]
public JsonResult GetEmergencyRegions([DataSourceRequest]DataSourceRequest request, string searchterm)
{
var emergencyRegions = _repository.GetEmergencyRegionBySearchTerm(searchterm);
return Json(emergencyRegions.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
App.js
$scope.gridOptions = {
columns: [{
field: "Description",
title: "Beschreibung"
}, {
field: "Region",
title: "Region"
}, {
field: "Phone",
title: "Telefon"
}, {
field: "HasPointOfSale",
title: "PoS"
}],
pageable: true,
dataSource: {
pageSize: 5,
transport: {
read: function (e) {
$http.jsonp('/Data/GetEmergencyRegions')
.then(function success(response) {
e.success(response.data);
}, function error(response) {
alert('something went wrong')
console.log(response);
})
}
}
}
};
View with the Grid
<kendo-grid options="gridOptions">
</kendo-grid>
On Stackoverflow I already found something with adding ?callback=JSON_CALLBACK
to the jsonp URL
but it didn't help.
Notice
When I remove the JsonRequestBehavior.AllowGet
inside my Controller, I don't get the error but then I get the status Code 404
.