Partial view not showing MVC razor

This is my first time using partial views and I cannot get the actual partial view. The ajax function is called, the controller gets hit, and the warning in the ajax call shows me that there is a partial view. But, with errors logged to the console (or warning), my div stays the same empty. My app is an MVC4 app, but I'm sure I just made a stupid mistake somewhere, not an MVC error :)

Take a few hours of surfing the web, I would be really happy if someone can help me get this working and all the code / ajax tips / comments I loved!

public PartialViewResult Groups()
        var person = _userRepository.GetCurrentUser();
        var connections = (from c in person.Person1 select c).ToList();
        var groups = _context.Groups.Where(g => g.GroupId == 1);

        var all = new GroupViewModel()
                          Connections = connections,
                          GroupDetailses = (from g in groups
                                                new GroupDetails
                                                        Name = g.Name,
                                                        StartDate = g.StartDate,
                                                        StartedById = g.StartedById,

        return PartialView("Groups",all);


My PartialView

@model Mvc4m.Models.GroupViewModel


    @Html.ActionLink("Create New", "Create")
<h3>Create new Group</h3>
<div class="ui-widget">
    <label for="group">Groupname: </label>
    <input id="group" />
    <button onclick="addGroup()">Add</button>

@foreach (var item in Model.GroupDetailses)
    @Html.LabelFor(model => item.Name)<text> : </text>
    @Html.DisplayFor(model => item.Name)
    function addGroup() {
                    Name: $("#group").val()


My Ajax call to profile / index

@model Mvc4m.Models.ProfileView

    ViewBag.Title = "Index";


<div id="test" style="background-color:Aqua; width:200px; height:100px"></div>

<button onclick="load()"></button>

<script type="text/javascript">
function load() {
        type: "GET",
        url: '/Profile/Groups',
        dataType: 'html',
        success: function (response) {
        error: function (xhr, status, error) {
            alert(status + " : " + error);





source to share

1 answer

Turns out the code is working, reloading visual studio did the trick! How I hate VS sometimes ...



All Articles