U
U
User992018-04-10 15:11:36
JavaScript
User99, 2018-04-10 15:11:36

How to load partial view automatically after page load?

The user clicks on

<td>@Html.ActionLink("Редактировать","Studedit", new {id=s.ID })</td>

in the representation Studedit loading student data
@using (Html.BeginForm("Studedit", "Praktika", FormMethod.Post))
                {
                    <fieldset>
                        @Html.HiddenFor(m => m.ID)
                        <p>@Html.LabelFor(m => m.FAM, "Фамилия:")</p>
                        <br />
                        @Html.EditorFor(m => m.FAM)
                        <br />
                        <p>@Html.LabelFor(m => m.IM, "Имя:")</p>
                        <br />
                        @Html.EditorFor(m => m.IM)
                        <br />
                        <p>@Html.LabelFor(m => m.OTC, "Имя:")</p>
                        <br />
                        @Html.EditorFor(m => m.OTC)<br />
                        <p><input type="submit" value="SAVE" /></p>
                    </fieldset>
                }
                <hr />
<div id="divsostav">
                </div>

at the end, at the bottom, I want to load an automatic partial view that displays people living together from another table. So far, I'm only able to load the partial view after the button is clicked.
<script type="text/javascript">
        $(function () {
            $.ajaxSetup({ cache: false });
            $('#sostav').click(function (e) {
                e.preventDefault();
                $('#divsostav').load('@Url.Action("Sostav", "Praktika")')
            });
        });
    </script>

I tried like this but it doesn't work:
<script type="text/javascript">
        $(function () {
            $.ajaxSetup({ cache: false });
            $.load(function (e) {
                e.preventDefault();
                $('#divsostav').load('@Url.Action("Sostav", "Praktika")')
            });
        });
    </script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
M-ka, 2018-04-10
@M-ka

api.jquery.com/load it describes when it starts .... I think you should think about what and when and where it is loaded

hint for those in the tank
кое что загружается позже, чем нужно....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question