blazes816
08-23-2006, 04:49 PM
Hey. I told you I was done with the stupid quetions, but I guess I lied. I'm learning ajax and have this simple script:
var xmlHttp;
function createRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function createpost(){
createRequest();
var url = "preview.php";
var query = document.getElementById("letterbody");
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = StateChange;
xmlHttp.send(query);
}
function StateChange(){
if(xmlHttp.readyState == 4){
alert(xmlHttp.request.ResponseText);
}}
So I hit the preview button, and it links to createpost(); But the whole page reloads and the response isn't alerted. Here's preview.php:
<?php
print 'bleh!';
?>
var xmlHttp;
function createRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function createpost(){
createRequest();
var url = "preview.php";
var query = document.getElementById("letterbody");
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = StateChange;
xmlHttp.send(query);
}
function StateChange(){
if(xmlHttp.readyState == 4){
alert(xmlHttp.request.ResponseText);
}}
So I hit the preview button, and it links to createpost(); But the whole page reloads and the response isn't alerted. Here's preview.php:
<?php
print 'bleh!';
?>