function state()
{
var x=document.getElementById("count").value;
document.write(x);
if(Window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readystate==4 && xmlhttp.status==200)
{
document.getElementById("response").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","getdata.php?val=".+x,"true");
xmlhttp.send();
}
}
This is myfirst time using ajax....i wanted to send the value in 'x' to getdata.php...........function state() is triggered when i choose a value from dropdown and click a button.....document.write() is working if xmlHttpRequest object is not created...and how do i know if the value in string x is being passed to getdata.php...please answer...
document.write()will wipe out all the content of the page and create a new blank document before writing.$_GETarray in your php script to see if it is being passed, or look in your network tab of the dev tools of your particular browser. If you need to log information on the browser side useconsole.logfunction, it will print messages to the console of the dev tools.