Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Help please, loading javascript into a div with ajax

    Help please, is that I want to load several different sliders within a div with ajax but the sliders need javascript code and does not run the show. Here you have an example of what happens to me and ajax code. I'm desperate to see if anyone helps me out, thanks. Sorry for my english, I'm from Spain.

    Example:

    https://dl.dropboxusercontent.com/u/...74/ejemplo.rar

    Code ajax:

    Code:
    <script>
    
    function nuevoAjax(){
    
        var xmlhttp=false;
        try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
        try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
        xmlhttp = false;
        }
        }
    
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
        
    } 
    
    
    
    function Cargar(url){
    
    
    var centro_galeria = document.getElementById('centro_galeria'); 
    
          
    ajax=nuevoAjax(); 
    ajax.open("GET", url,true); 
    
    ajax.onreadystatechange=function(){
    
    if(ajax.readyState==4){
    	
    
    centro_galeria.innerHTML=ajax.responseText;
    
    }
    
    }
            
    ajax.send(null);
    
    
    
    
    }
    
       
    </script>

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    144
    Thanks
    11
    Thanked 7 Times in 7 Posts
    If your url is calling javascript code then you will need to eval it: eval( '(' + your ajax response text + ')' );

    I have no idea what your url stream contains, so there's no way to assist you further. I am weary about running posted code snippets on my box for security reasons.

    Hope it helps.


  •  

    Posting Permissions

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