I'm trying to use AJAX via jquery with ASP.NET MVC, but I'm not able to hit my controller action and I think it might be because my url is not specified correctly.
The problem is, I'm not sure what is should be!
Say I have a controller named "Home", and an action named "AjaxAction", would the jquery look like this?
$.get("Home/AjaxAction");
This doesn't seem to be working for me, so I'm wondering if there's a more correct way to do this using Html helpers or something from ASP.NET MVC.
For instance, has anyone tried doing something like this?
<a href="#"
onclick="doSomeFunction('<%= Url.Action("AjaxAction", "Home") %>')">
Click Me
</a>
<script>
function doSomeFunction(url)
{
$.get(url);
}
</script>
Would that work or am I barking up the wrong tree? I've tried it myself but it's not working, but I'm not sure if it's because I'm doing something wrong or if it's because the entire approach is incorrect.