Hi
I am trying a very simple AJAX script where when you click a button it sends a query string to a php file to echo the string into a div which is static at the moment.
Heres the javascript:
[CODE] // Change the value of the outputText field
function setOutput(){
if(httpObject.readyState == 4){
document.getElementById(‘outputText’).innerHTML = httpObject.responseText;
}
}
// Implement business logic
function doWork(){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open(“GET”, “ajaxvote.php?inputText=hello”;
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
Heres the button and the div
[CODE]<form name=”testForm”>
Input text: <input type=”button” value=”TD” onchange=”doWork();” name=”inputText” id=”inputText” />
</form>
<div name=”outputText” id=”outputText”> </div>
And if you need it heres the script inside the php file
[CODE]if (isset($_GET[‘inputText’])){
echo strtoupper($_GET[‘inputText’]);
}
Thanks in advance