sendingdata-GET.html
<html>
<head>
<title>XMLHttpRequest - Sending Data with GET Query Strings </title>
<script type="text/javascript">
var xhr = false;
if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
function sendRequest(url)
{
var value = document.getElementById("t1").value;
var url = "http://localhost/Sending-Data-GET.php";
var newurl=url+"?"+"t1="+value;
if (xhr)
{
alert("xhr exists");
xhr.open("GET",newurl,true);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
var responseOutput = document.getElementById("responseOutput");
responseOutput.innerHTML = xhr.responseText;
}
}
}
xhr.send(null);
}
</script>
</head>
<body>
<h3>Send Data Using GET method Using Ajax</h3>
<form action="#" method="GET">
<input type="text" name="t1" id="t1">
<input type="button" name="rating" onclick="sendRequest();">
</form>
<br />
<div id="responseOutput"> </div>
</body>
</html>
Sending-Data-GET.php
<?
$v=$_GET['t1'];
echo "Server Side Coding $v";
?>