Ajax加载脚本不起作用

hi guy still having problems.. so though re write the question. got my external pages into a div on my index page.. great.. but cant seem to get java scripts to work.. i can get them to work once using this..

     <script>
        $.ajax({
        url: "pages/index.php",
        dataType: "html",
        success: function(html) {
          var target = $('.fademe');
        var targetHeight = target.outerHeight();
        $(document).scroll(function(e){
            var scrollPercent = (targetHeight - window.scrollY) / targetHeight;
            if(scrollPercent >= 0){
                target.css('opacity', scrollPercent);
            }
        }); 
        }
    });
</script>

but when i go to different page and come back it doesnt work... i put my scripts at the bottom of the main index page

<script>
    $.ajax({
        url: "pages/index.php",
        dataType: "html",
        success: function(html) {
            $('#st-accordion').accordion();
        };
    });

</script>

<script>
       $.ajax({
        url: "pages/index.php",
        dataType: "html",
        success: function(html) {
            $('#st-accordion2').accordion();
        }
    });

</script>


<script>
    $(function () {
        $.scrollUp();
    });
</script>

<!-- Fade Top Panel  -->
<script>
        $.ajax({
        url: "pages/index.php",
        dataType: "html",
        success: function(html) {
          var target = $('.fademe');
        var targetHeight = target.outerHeight();
        $(document).scroll(function(e){
            var scrollPercent = (targetHeight - window.scrollY) / targetHeight;
            if(scrollPercent >= 0){
                target.css('opacity', scrollPercent);
            }
        }); 
        }
    });
</script>

<script> 

    $ajax({
        url: "pages/index.php"
        dataType: "html",
        success: function(html) {
             $('#submit').click(function(){
            $.post("send.php", $("#mycontactform").serialize(),  function(data) {   });
                 $('#success').html('Message sent!');
                 $('#success').hide(2000);


                    $('#name1').val('');
                    $('#telephone').val('');
                    $('#email').val('');
                    $('#message').val('');

            });
        }


    });




</script>

<!-- Viberating Icons -->


<script>

    $(function() {
        var interval = 10;
        var duration= 1000;
        var shake= 3;
        var selector = $('.viberate'); /* Your own container ID*/
        $(selector).each(function(){
            var elem = this;
            var vibrateIndex;
            var timeoutIndex;
            $(this).hover( /* The button ID */
                function(){ 
                    vibrateIndex = setInterval(function(){
                      vibrate(elem); 
                    }, interval, 0);
                    timeoutIndex = setTimeout(function() 
                   {clearInterval(vibrateIndex)},1000);
                },
                function(){
                clearInterval(vibrateIndex);
                clearTimeout(timeoutIndex); 
                }
            );
        })

            var vibrate = function(elem){
                $(elem).stop(true,false)
                .css({position: 'relative', 
                left: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px', 
                top: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px'
            });
                        }
                    });

</script>
查看全部
weixin_33729196
weixin_33729196
2013/04/04 11:40
  • load
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复