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 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    jquery and ajax not working

    i have made one page this is page link
    http://pickthefights.com/fantansy-fi...482&page=fight
    the code of this page is this


    <script type="text/javascript">

    ////////////////////////////////
    //
    // Refreshing the DIV FANBOO2
    //
    ////////////////////////////////

    function refreshdiv_fanboo2(){

    // Customise those settings

    var seconds = 1;
    var divid = "fanboo2";
    var url = "http://pickthefights.com/fanboo2/?id=<?php echo $idvar ?>";

    // Create xmlHttp

    var xmlHttp_two = AJAX();

    // No cache

    var timestamp = fetch_unix_timestamp();
    var nocacheurl = url+"?t="+timestamp;

    // The code...

    xmlHttp_two.onreadystatechange=function(){
    if(xmlHttp_two.readyState==4){
    document.getElementById(divid).innerHTML=xmlHttp_two.responseText;
    setTimeout('refreshdiv_fanboo2()',seconds*1000);
    }
    }
    xmlHttp_two.open("GET",nocacheurl,true);
    xmlHttp_two.send(null);
    }

    // Start the refreshing process

    window.onload = function startrefresh(){
    setTimeout('refreshdiv_fanboo2()',seconds*1000);
    }

    </script>
    <script type="text/javascript">
    refreshdiv_fanboo2();
    </script>
    <div name="fanboo2" id="fanboo2"></div>

    now what ever i put in fanboo2 page it works fine but javascript or jquery is not working here is code of fanboo2 page, you can check page here http://pickthefights.com/fanboo2/?id=482# here is it is working but not here http://pickthefights.com/fantansy-fi...482&page=fight


    </script>
    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
    <script src="http://bxslider.com/sites/default/files/jquery.bxSlider.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $('#slider1').bxSlider();
    });
    </script>

    <ul id="slider1">
    <li>Slide one content</li>
    <li>Slide two content</li>
    <li>Slide three content</li>
    <li>And so on...</li>
    </ul>

    please help me out i want to make java script work on both of this page

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    If you perform an Ajax request to "fanboo2" page you'll only retrieve the HTML source code that the "fanboo2" page outputs. The output may include some Javascript source, but it won't be executed automatically.

    Usually it doesn't make sense to do an Ajax request to a "fully fledged" page (which includes the output of the whole document including DOCTYPE, <html>, <head> etc.) because Ajax won't use and doesn't need this information (because you are already on a fully fledged page ... no need to create another one). So usually you only output the crucial part in your Ajax page and let the calling page do all the work (including execution of any Javascript code which can manipulate the newly included HTML parts).


  •  

    Posting Permissions

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