Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Zac 239 posts 541 karma points
    Nov 25, 2013 @ 19:47
    Zac
    0

    v6 Surface Controller ajax get CurrentPage

    We're trying to get the CurrentPage in a Surface Controller in v6.1.5 when the Surface controller is posted via ajax (not from a begin form request).

    our ajax call looks like this:

            $.ajax({
                url:"/umbraco/surface/searchresults/changepage",
                type: "POST",
                cache: false,
                data: $(this).serialize(),
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                    $(".productListings").empty().append(data);
                }
            });

    The page posts to the surface controller fine and the model posted is parsed correctly, but we can't access the CurrentPage model.
    We've tried several methods to get the CurrentPage but haven't found one that works.  We're currently posting the uformpostroutevals with the form, but don't know how to force the CurrentPage to be set (the UmbracoContext.Current.PageId is null).

    Is it possible to use an ajax post and still maintain the UmbracoContext.Current properties?

  • Scott 95 posts 277 karma points
    Nov 25, 2013 @ 22:19
    Scott
    0

    Did you try to use CurrentPage.Id in the SurfaceController?

    I do with no trouble at all.

  • Zac 239 posts 541 karma points
    Nov 25, 2013 @ 22:35
    Zac
    0

    Our issue is with ajax posts.  The CurrentPage object is null in ajax posts to the SurfaceController (at least for me).  

    In normal postback and non-ajax methods, the CurrentPage object is populated.

     

  • Tom 713 posts 954 karma points
    Mar 07, 2014 @ 01:54
    Tom
    0

    Hi I also have the same issue.

    Is there a workaround when using ajax posts short of putting the page id in the request and resolving it using umbraco?

  • Zac 239 posts 541 karma points
    Mar 07, 2014 @ 02:14
    Zac
    0

    I believe we ended up passing the page id in with the ajax request and resolving it using the ApplicationContext

Please Sign in or register to post replies

Write your reply to:

Draft