Beginner PHP Tutorial – 172 – Loading in file Contents to a DIV Part 1

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

9 responses to “Beginner PHP Tutorial – 172 – Loading in file Contents to a DIV Part 1”

  1. sanjib karki Avatar

    Code to share
    <html>
    <head>
    <script type="text/javascript">
    function load() {
    <!– alert('Works.'); –>
    if(window.XMLHttpRequest) {
       xmlhttp = new XMLHttpRequest();
    } else {
      xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    }
    xmlhttp.onreadystatechange = function() {
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
       document.getElementById('adiv').innerHTML = xmlhttp.responseText;
     }
    }
    xmlhttp.open('GET', 'include.inc.php', true);
    xmlhttp.send();

    }
    </script>

    </head>

    <body>
    <input type="submit" onclick="load();">
    <div id="adiv"></div>
    </body>
    </html>

    <?php
    /* i just wrote the open php tag n close php tag on becoz if not, it will show the comments
    the below code will include the include.inc.php but it refresh the whole page
    <?php
    if(isset($_GET['show'])) {
      include $_GET['show'];
    }
    ?>
    <input type="submit" onclick="window.location='index1.php?show=include.inc.php'">
    */
    ?>

  2. silenthunter748 Avatar

    great work man……..!

  3. WegHuZ Avatar

    Woah woah woah, u went abit fast in the beginning there Alex didnt you? xD

  4. zanpaktuh Avatar

    Yes, the extension file doesn't really matter. As long as they are htm, html, php. In fact, for the first one, you don't need to specify the extension file because it is the index.

  5. marte thompson Avatar

    Do both files need to be .php files? Can the first one be an .html file?

  6. Ron lim Avatar

    thanks again

Leave a Reply

Your email address will not be published. Required fields are marked *