I am trying to change some data on my page using Ajax. This is a piece of code that does it:
<%= Ajax.ActionLink("Rate Up", "RatePost", new { postId = post.Id, rating = 1 }, new AjaxOptions { UpdateTargetId = string.Format("postRating_{0}", count) })%>
The problem is that RatePost actio开发者_如何学Gon is not called after click on this link. Instead, the parent view action is being called. How can I avoid this and just call the RatePost action with parameters I specified?
The code seems to be correct.
Verify that you included the Microsoft Ajax scripts in your view:
<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript">/script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
If something fails in the javascript generated by Ajax.ActionLink
, the click action is not cancelled.
精彩评论