Preloader Asp.net MVC

3

How can I make a preloader (loading ...) while it is rendering the view in @RenderBody ?

In search I just found examples using Partial, but Views not

Any ideas?

    
asked by anonymous 21.08.2014 / 21:24

1 answer

1

There is not much secret:

Controller

public JsonResult MinhaAction(int id)
{
    // Preenchimento de 'meuJson', e tal
    return Json(meuJson);
}

View

I'm using jQuery, and assuming you've already found a "loading" screen somewhere. I'm going to assume it stays inside a <div> whose Id is "loading":

$('#meuLink').click(function()
{
    var action = '@Html.ResolveUrl("~/MeuController/MinhaAction/")' + $('#campoId').val();
    $('#carregando').show()
    $.getJSON(action, null, function(variavelDeCallback) 
    {
        // Faça aqui o que precisa com 'meuJson'
        $('#carregando').hide()
    });
});
    
21.08.2014 / 21:47