2011-06-08 71 views
0

不工作我有一个页面dashboard.asp它打开一个对话框,并用ajax加载... profile.aspSafari浏览器:jQuery的功能在AJAX加载的内容

profile.asp有相关的配置文件的功能的各种jQuery函数。一切都很好接受Safari不会在加载的内容中加载$(document).ready

第二个问题应该是包括<script src="jquery.js"></script>在ajax加载页面以及父页面。

代码中dashboard.asp

<script language="javascript"> 
    $(document).ready(function(){    
     $("a[rel=profile]").live('click',function() {         
      var profileURL = $(this).attr('href'); 
      var title = $(this).attr('title'); 
      $.ajax({ 
       url: profileURL, 
       cache: false, 
       success: function(data) { 
        $('html, body').animate({ scrollTop: 0 }, 0); 
        $("#overlayer").fadeIn(); 
        $('#profile_menu_wrapper').load('/profile.asp',{a:title},function(){ 
         $('#profile_menu_wrapper').fadeIn(1000); 
         $("#profile").html(data); 
         $("#profile").fadeIn(1000);                    
        }); 
        } 
      });         
      return false; 
     }); 
    }); 
</script> 

的正常工作并打开,因为我想一个对话框......

但内profile.asp

<script language="javascript"> 
    $(document).ready(function(){ 
     alert("Ready") 
    }); 
</script> 
代码

不运行...

+0

你可以发布代码示例吗? – Ant 2011-06-08 08:01:43

+0

我已经添加了一些... – 2011-06-08 08:17:25

回答

0

唉!

我已经离开<html><body>等在Ajax加载的内容,这是搞砸了一切!

非常感谢您的回答,他们认为他们在上下文中是正确的。

1

变化profile.asp代码如下:

<script language="javascript"> 
    $(document).ready(InitProfileJqueryFunctionality); 

    function InitProfileJqueryFunctionality() { 
     alert("Some stuff"); 
    } 
</script> 

然后更改Dashboard.asp代码来调用加载页面内的功能,如果它存在。

<script language="javascript"> 
    $(document).ready(function(){    
     $("a[rel=profile]").live('click',function() { 
      $("#profile").hide();          
      var profileURL = $(this).attr('href'); 
      var title = $(this).attr('title'); 
      $.ajax({ 
       url: profileURL, 
       cache: false, 
       success: function(data) { 
        $('html, body').animate({ scrollTop: 0 }, 0); 
        $("#overlayer").fadeIn(); 
        $('#profile_menu_wrapper').load('/profile.asp',{a:title},function(){ 
         $('#profile_menu_wrapper').fadeIn(1000); 
         $("#profile").html(data); 
         $("#profile").fadeIn(1000);   
         if (typeof(InitProfileJqueryFunctionality) != 'undefined') 
          InitProfileJqueryFunctionality();           
        }); 
        } 
      });         
      return false; 
     }); 
    }); 
</script> 

我会说这是一个好主意,让加载jquery.js和在profile.asp页面引用,因为这则让您灵活正常打开页面(例如,不通过AJAX)和它仍然有效。

+0

还是没有...没有警报nadda。 :\ – 2011-06-08 08:47:51

相关问题