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

01-17-2011, 02: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);

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) {
return false;

does anybody have any suggestions?

thanks heaps!

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

01-31-2011, 12:43 AM

01-31-2011, 01:46 AM
This might help you:

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