Error in developing my first AJAX example. . . .
-
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;
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>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>I found one another problem is that php file also not run when i try to run it directly..... :(
-
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;
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>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>I found one another problem is that php file also not run when i try to run it directly..... :(
-
:wtf: he just mentioned running a php directly. Solution: 1) Even though WAMP is installed on ur system, it might not be configured properly, refer to the prev post 2) You are running files from the folder. instead, add "Listen 127.0.0.1:80" in ur httpd.conf (apache config file), then open any browser and type "localhost" in address and hit enter. also rename the html file to index.html so it is served to the browser without and explicit input. 3) "I ran php directly" is the fastest way to achieve defame on any php forum.. also, a starter tip: never use short php tag (", i learnt this the hard way :/ -- Modified Saturday, October 23, 2010 5:21 PM
-
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;
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>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>I found one another problem is that php file also not run when i try to run it directly..... :(