Thursday, June 19, 2008

the main php page:
<html>
<body>
<script language="javascript" src="/javascript/xmlhttpobj.js"></script>
<script language = "javascript">
var xmlHttp;

function ajax(){
xmlHttp = getXmlHttpObject();

var url = "ajaz2.php";
url = url + "?dog=" + escape(document.forms["hello"].cat.value);

xmlHttp.open("GET"-url-true);

xmlHttp.send(null);
alert("after send");
xmlHttp.onreadystatechange = StateChange();
}
function StateChange(){

if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
document.getElementById("output").innerHTML = xmlHttp.responseText;

}
}
</script>
<form name="hello">
Enter text here:
<input type="text" name= "cat" autocomplete="off"> <br>
<button type="button" name= "submit" onclick = "ajax();">Ajax!</button>
</form>

<div id="output">
<div class="output">Results will appear here</div>
</div>
</body>
</html>

and this is: ajaz2.php:
<?php
$input = rawurldecode($_GET["dog"]);
print "the input is: $input";
?>

Why does it only work with the alert()?
Ok- well I figured out if I use false instead of true in the open() call it works- and I understand that the problem was that something was happening too quickly- but is there another work around other than setting the the value in open() to false? When would one use true- and when would you use false?

I used to do a lot of programming in the olden days before the dinosaur and the internet. I did dBase- basic- foxpro- a lot of VB- and some others. In the past 10 to 15 years- I ve gotten away from it and have done more programming management than anything else. I d like to get back into coding- but there seems to be a lot of choices.

What is the general consensus for a good programming path? C?- Java?- Ajax?- Python?- Perl?- .Net?- something else?

eval()? maybe?

Read this and reply

http://pinastro.wordpress.com/2008/06/11/enterprise-20-series-saga-begins/

I need some help with this simple ajax script. I am trying to just write something that will give an alert that says whatever is typed in the form field. My code is:
<html>
<body onLoad="clear()">
<script language="javascript" src="/javascript/xmlhttpobj.js"></script>
<script language = "javascript">
var xmlHttp;

function ajax(){
xmlHttp = getXmlHttpObject();
var url = "ajaz2.php";
url = url + "?input=" + document.forms["hello"].input.value;
xmlHttp.open("GET"- url- true);
xmlHttp.send(null);
xmlHttp.onreadystatechange = StateChange();
}
function StateChange(){

if(xmlHttp.readyState == 4){

alert(xmlHttp.responseText);
}
}
</script>
<form name="hello">
Enter text here:
<input type="text" name ="input"> <br>
<input type="button" name = "submit" onclick ="ajax();" value="Go Ajax!" height = "200px">
</form>
</body>
</html>

and the ajaz2.php file is:
<?php
$input = $_Get["input"];
echo $input;
return;

Any help would be wonderful. Thanks

No comments: