Copied to clipboard

Flag this post as spam?

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


  • Simon 2 posts 82 karma points
    Mar 04, 2023 @ 12:15
    Simon
    0

    Transfer data from JS callback.

    Hi

    We are currently using a third-party cookie solution and are having an issue reacting to callbacks from the service. The site is setup as a default "Umbraco Cloud" solution.

    The following script is currently included in our view and executed correctly - but we have no idea how to transfer the info we are looking for to our Model or anywhere else.

    <script type="text/javascript">
    window.addEventListener('CookieConsentGiven', function (event) {
    
       // The info we need is located in event.detail.user
      // Invoke call-back to c# (model or static class)
    
    }, false);
    

    We have looked into DotNet.invokeMethodAsync, but no luck so far (DotNet not recognized).

    Any help will be highly appreciated. What is the best practice in this case?

    Best regards Simon

  • Huw Reddick 1932 posts 6722 karma points MVP 3x c-trib
    Mar 07, 2023 @ 08:59
    Huw Reddick
    100

    Are you using jQuery? if so you could add an $ajax post/get to your event listener

  • Simon 2 posts 82 karma points
    Mar 14, 2023 @ 14:27
    Simon
    0

    Thank you @Reddick.

    I ended up using an ApiController and jQuery, as you suggested.

  • 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