Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Problem in learning AJAX with PHP

Problem in learning AJAX with PHP

Scheduled Pinned Locked Moved Java
javascriptphphtmltoolshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khurram_shahzad
    wrote on last edited by
    #1

    hi ... i m trying to make this me first simple AJAX example using PHP that shows message from PHP on clicking Button in HTML page .... but this case some prolem ... that is when click on button to show message then nothing is happen .... is also check WAMP ... so any idea or suggestion !!!! HTML CODE IS,

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>MyFirstAJAXProram</title>

    </head>

    <body>
    <script type="text/javascript">

    function JavaFunction() {
    var xmlhttp;
    <!--Getting XMLHttpRequest OR Active depends on browser support...-->
    if(window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
    } else {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function() {
    	if(xmlhttp.readystate == 4) {
    		document.timerForm.time.value = xmlhttp.responseText;
    	}
    }
    xmlhttp.open("GET", "phpfile.php", true);
    xmlhttp.send(null);
    

    }
    </script>
    <form name="timerForm">
    <input type="button" onclick="JavaFunction()"; />
    Time: <input type="text" id="timer" name="time" value="00:00:00" readonly="readonly" />
    </form>
    </body>
    </html>

    HERE's PHP CODE,

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <?
    echo("KHURRAM SHAHZAD");
    ?>
    </body>
    </html>

    L 1 Reply Last reply
    0
    • K khurram_shahzad

      hi ... i m trying to make this me first simple AJAX example using PHP that shows message from PHP on clicking Button in HTML page .... but this case some prolem ... that is when click on button to show message then nothing is happen .... is also check WAMP ... so any idea or suggestion !!!! HTML CODE IS,

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>MyFirstAJAXProram</title>

      </head>

      <body>
      <script type="text/javascript">

      function JavaFunction() {
      var xmlhttp;
      <!--Getting XMLHttpRequest OR Active depends on browser support...-->
      if(window.XMLHttpRequest) {
      xmlhttp = new XMLHttpRequest();
      } else {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }

      xmlhttp.onreadystatechange=function() {
      	if(xmlhttp.readystate == 4) {
      		document.timerForm.time.value = xmlhttp.responseText;
      	}
      }
      xmlhttp.open("GET", "phpfile.php", true);
      xmlhttp.send(null);
      

      }
      </script>
      <form name="timerForm">
      <input type="button" onclick="JavaFunction()"; />
      Time: <input type="text" id="timer" name="time" value="00:00:00" readonly="readonly" />
      </form>
      </body>
      </html>

      HERE's PHP CODE,

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
      </head>

      <body>
      <?
      echo("KHURRAM SHAHZAD");
      ?>
      </body>
      </html>

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      khurram_shahzad wrote:

      so any idea or suggestion

      Since this is the Java forum I suggest you post this elsewhere - possibly either JavaScript or PHP.

      Just say 'NO' to evaluated arguments for diadic functions! Ash

      K 1 Reply Last reply
      0
      • L Lost User

        khurram_shahzad wrote:

        so any idea or suggestion

        Since this is the Java forum I suggest you post this elsewhere - possibly either JavaScript or PHP.

        Just say 'NO' to evaluated arguments for diadic functions! Ash

        K Offline
        K Offline
        khurram_shahzad
        wrote on last edited by
        #3

        Oh i c ...... :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups