Obtain Javascript value in XML

webmasterbeta

New Member
I am unable to send value from AJAX function to XML. I have a text form element which calls a javascript function when any option is selected.In that I am creating a XMLHTTPObject and sending the text value to a php file. I wish to extract some information from a database using the value and store it as XML. Using responseXML I then populate those values in the other fields of the form . But the main problem I am facing now is how to read the data from the javascipt function to the php file. A simple $_GET doesnot work because it is not supported by the xml code in my php. Please find the code enclosed.

JAVASCRIPT FUNCTION

<script type="text/javascript">

var xmlHttp;
function example()
{
var url="link.php"
url=url+"?value="+ 4
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

</script>

I have given just the basic code which is not working.

LINK.PHP

<?php
header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
$val=$_GET['value];
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<value>';
echo "<V>" . $val. "</V>";
echo '</value>';
?>

The output doesnot print the value. Thus I am somehow not able to pass the value from the javascript function to the file.Could you please have a look and let me know where I am wrong.Is there some other format to get the values ?
 
Back
Top