When I submit form using button it works fine (renders PartialView in the menuload div):
<% using (Ajax.BeginForm("Menu", null, new AjaxOptions { UpdateTargetId = "menuload", HttpMethod = "POST", LoadingElementId = "status-waiting" }, new { @id = "menuFormControl", enctype = "multipart/form-data"}))
{ %>
<input id="menuFormControlsubmit" type="submit" value="submit" ) />
<% } %>
But I want to do it using javascript, to load page parts. I try this:
<% using (Ajax.BeginForm("Menu", null, new AjaxOptions { UpdateTargetId = "menuload", HttpMethod = "POST", LoadingElementId = "status-waiting" }, new { @id = "menuFormControl", enctype = "multipart/form-data"})){ } %>
<script language="javascript" type="text/javascript">
$("#menuFormControl").submit();
</script>
But it renders my PartialView on a whole page.
The code of the controller:
public ActionResult Menu()
{
return PartialView("~/Views/Shared/MenuUserControl.ascx");
}
When you call
you are making the form be POSTed just like it would if you had used a traditional form (instead of an AJAX form). You will have to post the content of the form to the server using AJAX and insert the response.
Try something like