I have an ajax form in asp.net mvc that is simple:
<% using (this.Ajax.BeginForm("LatestBlogPosts", "Blog", null, new AjaxOptions { UpdateTargetId = "blogPostPanel" }, new { id = "BlogPostForm" })) { %>
<div class="panel" id="blogPostPanel">
<img src="/images/ajax-loader.gif" alt="ajax-loader" />
</div>
<% } %>
I want to trigger a form submission when loading a document. Presumably, this should trigger a controller action and return a result that should be replaced with a DIV placeholder. If I add the SUBMIT button to the form, it works fine, but when I call the submission via jQuery, the whole page is updated, and the content returned by the server is displayed on the newly displayed page. Here is my jQuery code:
<script type="text/javascript">
$(document).ready(function() {
$("#BlogPostForm").submit();
});
</script>
Anyway to do this?
source
share