简体   繁体   中英

How to load Razor partial view in jQuery without using MVC?

I am working on a Umbraco 7 project started without MVC implemented. I try to implement a loading without page refresh. I am stuck now because I need some Razor code to get Umbraco information but I need jQuery to refresh without page refresh.

Here my code:

$(function () {
            $.ajaxSetup({
              cache: false
            });
            $('#filterButton').click(function(){
                $('#content').html(@Html.Partial("~/Views/Partials/Preferences.cshtml"));
            })
        });

I tried with .load() with .html using @Html.Action , @Html.Partial etc, but nothing works. I know it is really simple to link a controller to an action like this but it will take me to much time now to change everything.

Can you say me if it is possible or not?

Please jquery try

 $('#content').load("/Partials/Preferences");

another html helpers try @{ Html.RenderAction("Preferences","Partials"); } @{ Html.RenderAction("Preferences","Partials"); }

Syntext For

@Html.RenderAction(Action, Controller, Route)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM