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.

help set ajax cookie

5 posters

Go down

In progress help set ajax cookie

Post by infotmt Sun 16 Jan - 22:36

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)");
});
infotmt
infotmt
New Member

Posts : 6
Reputation : 1
Language : english

http://raovat24.forumvi.com

Back to top Go down

In progress Re: help set ajax cookie

Post by Ape Mon 17 Jan - 0:23

@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
Ape
Ape
Administrator
Administrator

Male Posts : 19084
Reputation : 1988
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

In progress Re: help set ajax cookie

Post by Niko Mon 17 Jan - 2:47

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:
Niko
Niko
Helper
Helper

Male Posts : 3100
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

infotmt likes this post

Back to top Go down

In progress Re: help set ajax cookie

Post by zzlasperpen Mon 17 Jan - 7:14

I need it too
zzlasperpen
zzlasperpen
Forumember

Male Posts : 55
Reputation : 3
Language : VietNam

https://raovat24.forumvi.com/

Back to top Go down

In progress Re: help set ajax cookie

Post by infotmt Mon 17 Jan - 7:34

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
infotmt
infotmt
New Member

Posts : 6
Reputation : 1
Language : english

http://raovat24.forumvi.com

Back to top Go down

In progress Re: help set ajax cookie

Post by TheCrow Mon 17 Jan - 8:08

@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.
TheCrow
TheCrow
Manager
Manager

Male Posts : 6898
Reputation : 794
Language : Greek, English

https://forumote.forumotion.com

infotmt likes this post

Back to top Go down

In progress Re: help set ajax cookie

Post by infotmt Mon 17 Jan - 8:24

@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
infotmt
infotmt
New Member

Posts : 6
Reputation : 1
Language : english

http://raovat24.forumvi.com

Niko likes this post

Back to top Go down

In progress Re: help set ajax cookie

Post by Niko Mon 17 Jan - 15:57

@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);
              }
        });
    });
Niko
Niko
Helper
Helper

Male Posts : 3100
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

Ape likes this post

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum