Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to reload only ADs !? WordPress

  • REFUNDED

Hello

I need to reload all ADs in a page, like banners scripts and google adsense script.

I'm on a WordPress install and got acces to FTP.

I tried a jQuery.getScript. It works for a script containing some funtions but the Ads script contains a "document.write". Some of the script i need to reload are in the middle od the theme template like :
<div id="headerAd">
<script src="http://adsite.com/myscript.php?id=123"></script>
</div>


I've also tried a .get, a .load but same as above : the document.write is giving me some trouble.

So my final question is :
<strong>How can i reload all ADs</strong> (image banners, flash banners, video banners, iframe ADs and google adsense script) <strong>in a WordPress page/post on a ajax click ?</strong>

Answers (2)

2011-08-26

Svilen Popov answers:

$(document).ready(function() {
$("#refresh").click(function() {
$('#headerAd').html('<script src="http://adsite.com/myscript.php?id=123"></script>');
});
});


or

$(document).ready(function() {
setInterval(function() {
$('#headerAd').html('<script src="http://adsite.com/myscript.php?id=123"></script>');
}, 10000);
});


Julio Potier comments:

Hello

1. <script> tags are stripped from .html for security reasons
2. i tried this : .html('<sc'+'ript src="http://adsite.com/myscript.php?id=123"></scr'+'ipt>');
Scripts seems to been not "executed"/"evaluated" (i don't know how do say this) in a .html jQuery function :/

Did you try your code ?

Thank you


Svilen Popov comments:

Try this
<script>
setInterval(function() {
document.write('<scrip'+'t src="your script"></scr'+'ipt>');
}, 90);
</script>


Julio Potier comments:

It does not work, i think a web browser can not write script for security purposes.
I tried
<script>
setInterval(function() {
document.write('<scrip'+'t>alert(123);</scr'+'ipt>');
}, 90);
</script>

but no popup :/

Sorry !


Julio Potier comments:

i found a way to achieve that :

i add an <iframe id="myId" src="a_template_file.php">
the template file contains the "<script ...>"
Then, i do a jquery('#myId").attr('src', 'a_template_file.php');
So the iframe reloads the src file and so the script reloads !

See you

2011-08-27

ej_emman answers:

try to place it top of you template file before <html>

<?php header("Pragma: no-cache"); ?>

//then use the script
<script>

setInterval(function() {

document.write('<scrip'+'t src="your_script"></scr'+'ipt>');

}, 100);

</script>


Julio Potier comments:

It does not work, i think a web browser can not write script for security purposes.
I tried

<script>
setInterval(function() {
document.write('<scrip'+'t>alert(123);</scr'+'ipt>');
}, 90);
</script>


but no popup :/

Sorry !


Julio Potier comments:

i found a way to achieve that :

i add an <iframe id="myId" src="a_template_file.php">
the template file contains the "<script ...>"
Then, i do a jquery('#myId").attr('src', 'a_template_file.php');
So the iframe reloads the src file and so the script reloads !

See you