Hey...should be pretty easy..
I am just right now trying to get it to work...just pass in a string, and then document.write the result...but it isnt wooorking 🙁
here is my ajax:
function saveTreeview(url,dataToSend){
var pageRequest = false
if (window.XMLHttpRequest) {//all browsers except IE
pageRequest = new XMLHttpRequest()
}
else if (window.ActiveXObject){ //Internet Explorer
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e) {
try{
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else return false
pageRequest.onreadystatechange=function() {
var str = pageRequest.responseText;
document.write(str);
}//end function
if (dataToSend) {//if data is not null. This is where the data is sent to the php file, using POST
var treeData = 'treeData=' + dataToSend;
pageRequest.open('POST',url,true);
pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
pageRequest.send(treeData);
}
else {
pageRequest.open('GET',url,true)
pageRequest.send(null)
}
}
the button:
<center><input type="button" name="save" id="btnSave" value="Save" onclick="saveTreeview('treeviewQuery.php','test')"/></center>
and finally the litle php code saved in treeviewQuery.php:
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/rei_web/employee_area/conf.inc.php'); //logging in to sql server
if(isset($_POST['treeData'])){
echo $_POST['treeData'];
}else{
echo "error";
}
?>
ya..anyone see the ...probably stupid... mistake that I am not seeing >.<
thanks!