I’m trying to create simple Ajax call, but after clicking the link I get a blank page with “Test” string in top left corner:
In my Details view I have:
@Ajax.ActionLink("test", "AddPositive", new AjaxOptions() { UpdateTargetId = "countDiv" })
<div id="countDiv">
</div>
In controller:
public string AddPositive()
{
String test = "Test";
return (test);
}
Action does get called.
In _Layout.cshtml I imported.
<script src="@Url.Content("/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
It’s probably something really simple, but still cannot figure it out after going trough a few beginners tutorials for Ajax. Appreciate any help, thanks!
You are missing jquery and jquery.unobtrusive-ajax file.
Either there i bug in
MicrosoftMvcAjax.jsor M.S. has forgot to mention these files on their Tutorial. I hardly use this feature (@Ajax.ActionLink) so its tough for me figure out why it didnt worked without jQuery files.