Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Issue with JS loading on ajax loaded tabs.

    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/dynamici...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;

    Code:
    <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!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript > AJAX forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    bump..

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    This might help you:
    http://zeta-puppis.com/2006/03/07/ja...l-the-revenge/

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •