SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax content loader bug?

    Heya.. first of all I cannot code Ajax.

    I found a Ajax script that changes content in a div by ID.

    It does the job, no errors, except that it cannot put the following into the div. It completely erases it (or atleast doesn't show it).

    (javascript only that turns into a 1x1 pixel image if no ad is in the system for this spot)
    <script language="javascript"><!--
    document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|513|1598245|0|243|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=[group];misc='+new Date().getTime()+'"></scri'+'pt>');
    //-->
    </script><noscript><a href="http://adserver.adtech.de/adlink|3.0|513|1598245|0|243|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" target="_blank"><img src="http://adserver.adtech.de/adserv|3.0|513|1598245|0|243|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" border="0" width="140" height="140"></a></noscript>
    But, the following does come through: (IFRAME version with fixed with and height)
    <IFRAME WIDTH="140" HEIGHT="140" SCROLLING="No" FRAMEBORDER="0" MARGINHEIGHT="0" MARGINWIDTH="0" SRC="http://adserver.adtech.de/adiframe|3.0|513|1598243|0|243|ADTECH;target=_blank;key=key1+key2+key3+key4;grp=[group]"><script language="javascript" src="http://adserver.adtech.de/addyn|3.0|513|1598243|0|243|ADTECH;loc=700;target=_blank;key=key1+key2+key3+key4;grp=[group]"></script><noscript><a href="http://adserver.adtech.de/adlink|3.0|513|1598243|0|243|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" target="_blank"><img src="http://adserver.adtech.de/adserv|3.0|513|1598243|0|243|ADTECH;loc=300;key=key1+key2+key3+key4;grp=[group]" border="0" width="140" height="140"></a></noscript></IFRAME>
    Why does the second one come through but the first one not?

    My guess is that the iframe version works because the iframce has a src value and that's what it uses (confirmed).

    Why is all javascript code cut out of this ajax function?

    What I am trying to accomplish... is delay the loading of my adtech banner javascripts because the way my layout is setup, it makes the screen go white / blank until everything is loaded.

    If there is another way of doing this, than with Ajax, please let me know. But for now, please help me out figure out why the IFRAME version works, but not the javascript version.

    EDIT: This is the bit of Ajax code I use that I'm calling through an onload command

    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    function ajaxpage(url, containerid) {
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    page_request.open('GET', url, true)
    page_request.send(null)
    }
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src", file);
    }
    else if (file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", file);
    }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }
    signature

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    am I not making myself understood? or is it impossible to do what I want to do?
    signature

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pleeeease, i hate thread bumping
    signature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •