...

View Full Version : Issue with JS loading on ajax loaded tabs.



Tidus
01-17-2011, 03:09 PM
Hi everyone,

So I am completely new to ajax (and not that familiar with JS) and I am struggling a bit trying to implement "tabs" into my project.

I am using the tabs found here (http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm) with pages loaded through ajax.

the issue I am having is that after the initial load of all the tab content, it seems that any javascript i have in any pages accessed through links (and loaded in the active tab) doesn't seem to be running. the main problem is having a tab with a form in it, and i am trying to submit the form using ajax and then load a confirmation page. i am aware i could be doing this the complete newb way, but being a newb this is a given hehe.

the script i am using to power the tabs is here;


<script type="text/javascript">
function ahah(url, target) {
document.getElementById(target).innerHTML = ' Fetching data...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target);};
req.open("GET", url, true);
req.send("");
}
}

function ahahDone(url, target) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
}
}
}

function load(name, div) {
ahah(name,div);
return false;
}</script>

does anybody have any suggestions?

thanks heaps!

Fou-Lu
01-17-2011, 04:13 PM
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript > AJAX forum.

Tidus
01-31-2011, 01:43 AM
bump..

venegal
01-31-2011, 02:46 AM
This might help you:
http://zeta-puppis.com/2006/03/07/javascript-script-execution-in-innerhtml-the-revenge/

Generally speaking, using Javascript to fetch HTML containing Javascript and making it execute is not a trivial task.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum