Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • using ajax to load content from php file without jquery ( TABS)

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 16
    Answer it

    i want to make a tabs that generating content from database based on what users click.

    i want to have a script which uses PHP, ajax and JSON if needed. but i don't want to use jquery.

    Could you please Help me?

    here is what i have right now

     

    <div class="category-links">
    <p class="cat-archive"><span> showing results from </span>
    <a href="#" class="active">general</a>
    <a href="#">mobile</a>
    <a href="#">Computer</a>
    <a href="#">internet</a>
    </p>
    </div>
    
    <div id="recent">
    <div class="postbox">
    //Loaded content goes Here
    </div>
    </div>

 2 Answer(s)

  • Hi,
    please get your desire code.
    <html>
    <head>
    <script>
    window.onload = function() {
      loadContent();
    };
    function loadContent() {
    
            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else {
                // code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if (this.readyState == 4 && this.status == 200) {
                    var x = document.getElementsByClassName("postbox");
                    x[0].innerHTML = this.responseText;
                }
            };
            xmlhttp.open("GET","phpResultFile.php",true);
            xmlhttp.send();
       
    }
    </script>
    </head>
    <body>
    <div class="category-links">
    <p class="cat-archive"><span> showing results from </span>
    <a href="#" onclick="loadContent()" class="active">general</a>
    <a href="#" onclick="loadContent()">mobile</a>
    <a href="#" onclick="loadContent()">Computer</a>
    <a href="#" onclick="loadContent()">internet</a>
    </p>
    </div>
    <div id="recent">
    <div class="postbox">
      
    </div>
    </div>
    
    </body>
    </html>
    This code will get the php file output and show in your div class name "postbox". If you want to pass the dynamic category to php file as variable so you need to change line.
     xmlhttp.open("GET","phpResultFile.php?q="+str,true);


     
  • ACADEMICSWRITER.com at your services for solving matlab and engineering assignments.

     

    ACADEMICSWRITER is able to provide you services for all programming languages that also includes statistical programming software’s like stata. Matlab assignments services is also a very integrated facility of ACADEMICSWRITER.COM.

     

    ACADEMICSWRITER provides you solution for all programming languages like java, C++, PHP, SQL etc.

     

    We are here to solve your engineering problems at ACADEMICSWRITER.COM. Academics writer facilitates you with engineering problems and engineering assignments of control systems, electrical systems and architectures.

     

    ACADEMICSWRITER.COM is here to provide your services for Autocad because our fleet of Civil engineers is working effectively to provide you best engineering assignments and their best structural solutions.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: