The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
5 posters

    help set ajax cookie

    infotmt
    infotmt
    New Member


    Posts : 6
    Reputation : 1
    Language : english

    In progress help set ajax cookie

    Post by infotmt January 16th 2022, 9:36 pm

    I have a code, I need to set a cookie for 30 minutes please help me
    Code:
    $(document).ready(function() {
        $("#newtopic").load("/f1- .ipbtable tbody tr .topictitle:lt(10)");
    });
    Ape
    Ape
    Administrator
    Administrator


    Male Posts : 19432
    Reputation : 2010
    Language : fluent in dork / mumbojumbo & English haha

    In progress Re: help set ajax cookie

    Post by Ape January 16th 2022, 11:23 pm

    @infotmt
    The topic was posted in the wrong section, so I have moved it to the correct section.
    Please read our forum rules: ESF General Rules



    help set ajax cookie Left1212help set ajax cookie Center11help set ajax cookie Right112
    help set ajax cookie Ape_b110
    help set ajax cookie Ape1010
    Niko
    Niko
    Helper
    Helper


    Male Posts : 3283
    Reputation : 254
    Language : English, Italian, French
    Location : Italy

    In progress Re: help set ajax cookie

    Post by Niko January 17th 2022, 1:47 am

    Dear @infotmt

    are you sure you are talking about cookies? Maybe you are referring to "cache", so that the result is stored in cache and not loaded every time? (in order to have a faster load on your website)

    Have a nice day :rose:

    infotmt likes this post

    zzlasperpen
    zzlasperpen
    Forumember


    Male Posts : 56
    Reputation : 3
    Language : VietNam

    In progress Re: help set ajax cookie

    Post by zzlasperpen January 17th 2022, 6:14 am

    I need it too
    infotmt
    infotmt
    New Member


    Posts : 6
    Reputation : 1
    Language : english

    In progress Re: help set ajax cookie

    Post by infotmt January 17th 2022, 6:34 am

    Niko wrote:Dear @infotmt

    are you sure you are talking about cookies? Maybe you are referring to "cache", so that the result is stored in cache and not loaded every time? (in order to have a faster load on your website)

    Have a nice day :rose:
    you are right, please help me
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    In progress Re: help set ajax cookie

    Post by TheCrow January 17th 2022, 7:08 am

    @infotmt,

    Your topic is not clear enough. Please provide us with some more details as to what this code will do and maybe a screenshot with it.

    TC.



    help set ajax cookie Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!

    infotmt likes this post

    infotmt
    infotmt
    New Member


    Posts : 6
    Reputation : 1
    Language : english

    In progress Re: help set ajax cookie

    Post by infotmt January 17th 2022, 7:24 am

    @TheCrow
    I mean
    jquery .load so I want it to cache so that next time I don't need to reload

    @Niko You said exactly what I meant

    Niko likes this post

    Niko
    Niko
    Helper
    Helper


    Male Posts : 3283
    Reputation : 254
    Language : English, Italian, French
    Location : Italy

    In progress Re: help set ajax cookie

    Post by Niko January 17th 2022, 2:57 pm

    @infotmt Here I am Wink

    I needed to change the script you provided because sadly in jQuery the function
    Code:
    .load()
    does not directly have cache support. For this reason we will turn this into
    Code:
    $.ajax


    Go to ACP > Modules > HTML & Javascript > Javascript codes management and create a new javascript with these settings, upon having verified that Javascript management is enabled:

    • Title: as you prefer
    • Where: in all pages (or in any case where the
      Code:
      #newtopic
      element is
      )
    • Code:
      Code:
      $(function() {
          var element = $("#newtopic");
          var targetPage = '/f1-';
          $.ajax({
                url: targetPage,
                cache: true,
                type:'GET',
                success: function(data){
                      var retrieveContent = $(data).find('.topictitle:lt(10)').html();
                      $(element).html(retrieveContent);
                }
          });
      });

    Ape likes this post


      Current date/time is November 11th 2024, 6:07 pm