<h5>Div-1</h5>
<button class="btn btn-primary mb-3" onclick="refreshBid()">Refresh Ad Unit</button>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-1');
});
</script>
</div>
var sizes = [
[300, 250]
];
var PREBID_TIMEOUT = 1000;
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var adUnits = [{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}];
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
});
var slot1;
googletag.cmd.push(function() {
slot1 = googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250]], 'div-1')
.addService(googletag.pubads());
googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
function refreshBid() {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
adUnitCodes: ['/19968336/header-bid-tag-0'],
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync(['/19968336/header-bid-tag-0']);
googletag.pubads().refresh([slot1]);
}
});
});
}
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Individual Ad Unit Refresh / Infinite Scroll</title>
<!-- required scripts -->
<script async src="//cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js"></script>
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
</head>
<body>
<!-- javascript -->
<script>var sizes = [
[300, 250]
];
var PREBID_TIMEOUT = 1000;
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var adUnits = [{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}];
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
});
var slot1;
googletag.cmd.push(function() {
slot1 = googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250]], 'div-1')
.addService(googletag.pubads());
googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
function refreshBid() {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
adUnitCodes: ['/19968336/header-bid-tag-0'],
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync(['/19968336/header-bid-tag-0']);
googletag.pubads().refresh([slot1]);
}
});
});
}
</script>
<!-- html -->
<h5>Div-1</h5>
<button class="btn btn-primary mb-3" onclick="refreshBid()">Refresh Ad Unit</button>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-1');
});
</script>
</div>
</body>
</html>