Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8618323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:04:57+00:00 2026-06-12T06:04:57+00:00

I am using DoubleClick for Publishers (DFP) ads , but when I using jquery

  • 0

I am using DoubleClick for Publishers (DFP) ads, but when I using jquery append, loading DoubleClick for Publishers (DFP) ads in one div, the ads block is empty. How to do it so that the ads could show nomorlly?

Demo link

Thanks.

<?php header("Content-type: text/html; charset=utf-8"); ?>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<?php if(!$_POST['number']){ ?>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=1.7.2'></script>
<script type='text/javascript'>
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function() {
    var gads = document.createElement('script');
    gads.async = true;
    gads.type = 'text/javascript';
    var useSSL = 'https:' == document.location.protocol;
    gads.src = (useSSL ? 'https:' : 'http:') + 
    '//www.googletagservices.com/tag/js/gpt.js';
    var node = document.getElementsByTagName('script')[0];
    node.parentNode.insertBefore(gads, node);
    })();
</script>
<script type='text/javascript'>
    googletag.cmd.push(function() {
        googletag.pubads().enableAsyncRendering();
        googletag.defineSlot('/17177879/ads_300_250_white_right', [300, 250], 'div-gpt-ad-1-1').addService(googletag.pubads());
        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
    });
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
    $(".bnews").live('click',function(){
        var nnum = $(this).attr('rel');
        googletag.cmd.push(function() {
            googletag.pubads().enableAsyncRendering();
            googletag.defineSlot('/17177879/ads_300_250_white_right', [300, 250], 'div-gpt-ad-' + nnum + '-1').addService(googletag.pubads());
            googletag.pubads().enableSingleRequest();
            googletag.enableServices();
        });
        $(this).css('display','none');
        $.ajax({
            url: "1.php", 
            dataType: "html",
            type: 'POST',
            data: 'number=' + nnum,
            success: function(data){ 
                $("#cc-wrap").append(data); 
            }               
        });
    });
});
</script>
<h1 class="bnews" rel="2">Append to div</h1>
<!-- some content here -->
<!-- ads_300_250_white_right -->
<div id='div-gpt-ad-1-1' style='width:300px; height:250px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1-1'); });
</script>
<div id="cc-wrap"></div>
<?php }else{ ?>
<h1 class="bnews" rel="<?php echo ($_POST['number']+1); ?>">Append to div</h1>
<!-- some content here -->
<!-- ads_300_250_white_right -->
<div id='div-gpt-ad-<?php echo $_POST["number"]; ?>-1' style='width:300px; height:250px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-<?php echo $_POST["number"]; ?>-1'); });
</script>
<?php } ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:04:58+00:00Added an answer on June 12, 2026 at 6:04 am

    You need to remove the two calls to the googletag.pubads().enableSingleRequest() function… it looks like this is stopping you from requesting more ads after you have appended. When I commented out that piece of code in the two places you are using it the script started working… it still seems a little bit broken though.

    This is your example with the line commented so that it works:

    <?php header("Content-type: text/html; charset=utf-8"); ?>
    <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
    <?php if(!$_POST['number']){ ?>
    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=1.7.2'></script>
    <script type='text/javascript'>
        var googletag = googletag || {};
        googletag.cmd = googletag.cmd || [];
        (function() {
        var gads = document.createElement('script');
        gads.async = true;
        gads.type = 'text/javascript';
        var useSSL = 'https:' == document.location.protocol;
        gads.src = (useSSL ? 'https:' : 'http:') +
        '//www.googletagservices.com/tag/js/gpt.js';
        var node = document.getElementsByTagName('script')[0];
        node.parentNode.insertBefore(gads, node);
        })();
    </script>
    <script type='text/javascript'>
        googletag.cmd.push(function() {
            googletag.pubads().enableAsyncRendering();
            googletag.defineSlot('/17177879/ads_300_250_white_right', [300, 250], 'div-gpt-ad-1-1').addService(googletag.pubads());
            //googletag.pubads().enableSingleRequest();
            googletag.enableServices();
        });
    </script>
    <script type="text/javascript">
    jQuery(document).ready(function(){
        $(".bnews").live('click',function(){
            var nnum = $(this).attr('rel');
            googletag.cmd.push(function() {
                googletag.pubads().enableAsyncRendering();
                googletag.defineSlot('/17177879/ads_300_250_white_right', [300, 250], 'div-gpt-ad-' + nnum + '-1').addService(googletag.pubads());
                //googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
            $(this).css('display','none');
            $.ajax({
                url: "1.php",
                dataType: "html",
                type: 'POST',
                data: 'number=' + nnum,
                success: function(data){
                    $("#cc-wrap").append(data);
                }
            });
        });
    });
    </script>
    <h1 class="bnews" rel="2">Append to div</h1>
    <!-- some content here -->
    <!-- ads_300_250_white_right -->
    <div id='div-gpt-ad-1-1' style='width:300px; height:250px;'>
    <script type='text/javascript'>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1-1'); });
    </script>
    <div id="cc-wrap"></div>
    <?php }else{ ?>
    <h1 class="bnews" rel="<?php echo ($_POST['number']+1); ?>">Append to div</h1>
    <!-- some content here -->
    <!-- ads_300_250_white_right -->
    <div id='div-gpt-ad-<?php echo $_POST["number"]; ?>-1' style='width:300px; height:250px;'>
    <script type='text/javascript'>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-<?php echo $_POST["number"]; ?>-1'); });
    </script>
    <?php } ?> 
    

    Let me know if you have any more questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I add a banner (728x90) or ads using Google's DoubleClick for Publishers
I've created a Windows Service that accepts commands from remote machines via WCF. One
I am using this code to go to other tab one double click: ondblClickRow:
I've got a situation that has turned my mind to mush and could use
I am using wpfToolkit:DataGrid in my application. If I tried to doubleclick on the
I've got an issue involving a website that I have been using VS 2008
how to update a table without redirecting the page using javascript or jquery this
Here is what i am using, but i get an error: private void listView1_DoubleClick(object
I have a WinForm application using a FlowLayoutPanel that displays .TIFF files that have
How do I capture a doubleclick event of the System.Windows.Forms.MonthCalendar control? I've tried using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.