I am using asp.net mvc 4, knockout-js within my application. I would like to ask how can i make an call from js file to the controller?
it works when i write this code into the view (razor) page:
<script type="text/javascript">
$(document).ready(function () {
var url = '@Url.Action("GetTechnicians", "Ticket")';
$.post(url, null, function (data) {
alert("get data");
});
});
</script>
now I would like to make the call in *.js file.
the problem is that Url.Action is invalid within js file.
My url mapping in global.asax is: "{culture}/{controller}/{action}/{id}",
signature of my controller looks like: public JsonResult GetTechnicians()
When I use in js file:
var url = "/Ticket/Technicians";
I get an error: "NetworkError: 404 Not Found - http://localhost/Ticket/Technicians"
I would like to know how to complete the call from js file?