0

I am a beginner so bear with me.

So I am trying to dynamically load this javascript easy slider into a div on my index page like this ...

switch($_GET['page'])  {

case '#YELLOW' : 

$page = '

<div id="slider">
    <ul>                
        <li><a href=""><img src="http://localhost/easy/archive/YELLOW/images/1.jpg" alt="" /></a></li>
        <li><a href=""><img src="http://localhost/easy/archive/YELLOW/images/2.jpg" alt="" /></a></li>
        <li><a href=""><img src="http://localhost/easy/archive/YELLOW/images/3.jpg" alt="" /></a></li>

    </ul>
</div>

'; 

<script type="text/javascript">
    $(document).ready(function(){   
        $("#slider").easySlider();
    }); 
</script>is 

break; 

But it only actually loads ever second time I click the link. What is going on here. Do I need to evaluate the javscript code? What would that mean here? Am I loading the javascript in at the wrong point? Why does it only break every couple times?

Thanks in advance

4
  • Those links you provided contain no intelligible information (the second one appears to be completely empty).
    – Pointy
    Commented Oct 15, 2011 at 15:44
  • The second link is the source of the above code. I am not exactly sure why nothing is showing up when it is clicked on. Sorry about that. It is there though.
    – user996988
    Commented Oct 15, 2011 at 16:03
  • Well, so long as HTTP requests to that URL result in zero bytes transferred to my browser, it doesn't do any good.
    – Pointy
    Commented Oct 15, 2011 at 16:04
  • did u tried onload function ?
    – Sudantha
    Commented Oct 15, 2011 at 16:21

1 Answer 1

1

If you are running that code via an ajax call it won't work.

The ready(function()); is called only once and it is when the webpage finishes loading the first time.

If you are appending that script directly into the page after it has loaded. You must remove the $(document).ready() and append $("#slider").easySlider(); directly to the html. (and preferably after the #slider exists in the html or it also won't work