weixin_33699914 2011-06-01 06:38 采纳率: 0%
浏览 44

Umbraco-使用Ajax加载内容

I'm new to Umbraco and only started to figure out the ins and outs of it.

Anyway, I've figured out on my own the way document types, macros, templates, xslt files work and am now trying to do some other stuff. Namely I need to load a document content using an AJAX call. It's basically a panel with a menu (dynamic, which I figured out how to load) that loads content depending on the menu item selected (the documents loaded with the menu). What I need to figure out is how to get that content using an AJAX call since I don't want to reload the page.

Is this done using Umbraco BASE extensions or am I off in my thinking here? If so, how exactly? Do I just write a class and then stitch together an HTML string in a method?

Thanks for the help

  • 写回答

3条回答 默认 最新

  • 狐狸.fox 2011-06-01 14:14
    关注

    Yup this is exactly the scenario that Base is used for.

    You can find documentation on using base here:

    http://our.umbraco.org/wiki/reference/umbraco-base/simple-base-samples

    For the consumption of base via AJAX then JQuery is the answer.

    http://api.jquery.com/jQuery.ajax/

    Here's a hacked together example (not tested code):

    $(document).ready(function ()
    {
        $(".buttonListener").click(function ()
        {
            $.ajax(
            {
                url: '/Base/TestAlias/Hello.aspx',
                success: function (data, textStatus, XMLHttpRequest)
                {
                    alert(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown)
                {
                    alert("Ka pow!");
                }
            });
            return true;
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?