2011-07-30 184 views
0

我通过ajax加载外部php页面。外部页面由基于jQuery的图像滑块组成。它不会被加载。在这里我通过Ajax调用页面。jquery图像滑块与ajax

<a href="javascript:void(0)" onclick="open_url('3bg.php','loaded');"> Load Jquery </a> 

它被加载但该页面内的导航功能不起作用。

这里是AJAX导航被称为

var please_wait = null; 

function open_url(url, target) { 
if (! document.getElementById) { 
    return false; 
} 

if (please_wait != null) { 
    document.getElementById("target").innerHTML = please_wait; 
} 

if (window.ActiveXObject) { 
    link = new ActiveXObject("Microsoft.XMLHTTP"); 
} else if (window.XMLHttpRequest) { 
    link = new XMLHttpRequest(); 
} 

if (link == undefined) { 
    return false; 
} 
link.onreadystatechange = function() { response(url, target); } 
link.open("GET", url, true); 
link.send(null); 
} 

function response(url, target) { 
if (link.readyState == 4) { 
    document.getElementById(target).innerHTML = (link.status == 200) ? link.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the fallowing errorcode: " + link.status; 
} 
} 

function set_loading_message(msg) { 
please_wait ='<img src="images/ajax-loader.gif"/>'; 
} 

我在哪里做的修正,使之与我的基于jQuery页面工作。

+0

您可以给出3bg.php输出的代码示例吗?在我看来,你的JS很好(但是,如果使用jQuery,为什么不使用它来进行ajax调用,代码更快)。 –

+0

您的3bg.php有可能会在$(document).ready()上触发的jquery代码,当您在当前页面上替换HTML时,该代码不会产生任何效果 – dakdad

回答