How to call my Asp.Net MVC view with ajax

0

I'm starting my studies with Asp.Net MVC and I'm having trouble getting a view from the main menu. I have an initial "_Layout" view with the following menu item:

<li>
  <input type="radio" name="tabs" class="rd_tabs" id="tab3">
  <label for="tab3">Currículo</label>
</li>

And I'm trying to call the controller / action in the following way:

@section Scripts{
    <script>
            $(document).ready(function () {
                $('#tab3').click(function () {
                    $.ajax
                        ({
                            url: "/Home/Curriculo",
                            type: 'GET',
                            success: function (dados) {
                                console.log("sucesso");
                            },
                            error: function (erro) {
                                console.log("falha");
                            }
                        });
                });
            })
    </script>
}

But nothing happens, even the function being executed and printing "success" on the console. I've tried calling the url in different ways but nothing worked.

I would like the help of colleagues to know where I am going wrong. Thanks!

    
asked by anonymous 23.09.2018 / 04:51

1 answer

0

Well try instead of success send the console print the data and look if there is an html code, what happens and that it returns on the same page the data you would have to do something with the page returned. >

I think you do not need ajax like this.

    $(document).ready(function () {
        $('#tab3').click(function () {
              window.location = "/Home/Curriculo"  

        });
    })
    
24.09.2018 / 01:15