Copied to clipboard

Flag this post as spam?

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


  • Zac 238 posts 539 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 Hugh Alexandar Petersen 87 posts 235 karma points
    Nov 25, 2013 @ 22:19
    Scott Hugh Alexandar Petersen
    0

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

    I do with no trouble at all.

  • Zac 238 posts 539 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 952 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 238 posts 539 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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies