question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refreshing on AJAX pages

See original GitHub issue

I can’t seem to get ads refreshing every 30 seconds and working for ajax pages. I have the ads refreshing but it currently doesn’t work once I change pages two or more times. This is what my code looks like right now.

$('.adunit:not(".display-block")').dfp({ dfpID: '52137663', enableSingleRequest: false, afterAllAdsLoaded: function() { setInterval(function() { jQuery.dfp(); }, '30000'); } });

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tinyearthcommented, Jan 24, 2017

@boooooooorbs You will need to use some of Google’s native methods in jquery.dfp.js beforeEachAdLoaded callback like such:

beforeEachAdLoaded: function (adUnit) {
	var slots = googletag.pubads().getSlots(); // returns array of Slot objects
	var slot = slots[slots.length - 1];
	var slotName = adUnit.attr('id');

	googletag.display(slotName);
	googletag.pubads().refresh([slot]);
}
0reactions
boooooooorbscommented, Jul 16, 2016

@samburgers could you please explain for someone who’s not that code savvy how you did it? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop refreshing page after ajax call? - Stack Overflow
If so - the page is refreshing not because of your code, but because whatever ajax you called manipulated the folder you were...
Read more >
Reload or Refresh a Page after Ajax Success using jQuery
You can use the location.reload() method to reload or refresh an entire web page or just the content inside an element. The .reload()...
Read more >
Why is my ajax call refreshing the page?
Try using preventDefault() , it's a jQuery function for preventing default actions called by the browser. First you should call an event ...
Read more >
What is the differencebetween refreshing the page and ajax ...
Ajax refresh is used to refresh only certain parts of the screen, thus avoiding the loading and rendering of the whole page. In...
Read more >
Using AJAX to Refresh a Section of a Page At a Specific Interval
Refreshing only a section of a page instead of reloading the entire page can be a nice touch for the user experience. Beyond...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found