3 Replies - 1352 Views - Last Post: 09 December 2011 - 02:38 AM

#1 andrei71   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 20-April 11

Cannot display a banner with javascript ?

Posted 06 December 2011 - 02:34 AM

hi,

i want to display a banner with javascript code.first i put the display js script on mysite.com(e.g) :

<script src="http://trackerexam.com/tracker.php?idsite=4&idreg=7" type="text/javascript"></script>


when the visitor come to mysite.com(e.g), the script above invisibly redirect to the trackerexam.com/tracker.php for insert the visitor data to the database and also display the advertisement banner from database.it was succesful to get the data in the trackerexam.com but it won't display the banner to mysite.com

trackerexam.com/tracker.php :

<?php
include "connection.php";
$advertisement = mysql_query("SELECT * FROM trackads WHERE id_ads='$idads'");
$banner = mysql_fetch_array($advertisement);

echo "<a href='http://$banner[url]'><img src='images/$banner[image]'></a>";   

?>


it won't echo the banner with <script src> code
what is the error,can you help me ?

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot display a banner with javascript ?

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4246
  • View blog
  • Posts: 13,461
  • Joined: 08-June 10

Re: Cannot display a banner with javascript ?

Posted 06 December 2011 - 06:53 AM

unless there is an explicit Javascript print statement, contents of a <script> tag are not displayed in the browser.

what would make more sense is an AJAX script that inserts the returned link via standard methods (e.g. innerHTML) into the document tree.
Was This Post Helpful? 0
  • +
  • -

#3 andrei71   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 20-April 11

Re: Cannot display a banner with javascript ?

Posted 08 December 2011 - 10:57 PM

sorry but i don't know how to use a AJAX script, so i use it with Javascript but it can't echoed the banner.but if i used include function from PHP i can display the banner

how to display the banner with javascript from database ?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4246
  • View blog
  • Posts: 13,461
  • Joined: 08-June 10

Re: Cannot display a banner with javascript ?

Posted 09 December 2011 - 02:38 AM

using an AJAX is part of using Javascript.

if you make use of a library that becomes dead simple.
<!-- include the jQuery linbrary -->
<script type="text/javascript">
$(document).ready(function() {
    $.get("tracker.php", {idsite: 4, idreg: 7}, function(data) {
        $("#container").html(data);
    });
});
</script>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1