Вот ещё 1 вариант...тут уже должно работать,но пишет что не обьявлены переменные data1 data2
js.js
----
var xmlHttp=createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
var XMLHttpVersions=new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
{
try
{
xmlHttp= new ActiveXObject(XmlHttpVersions[i]);
}
catch(e) {}
}
}
if (!xmlHttp)
alert("error of creating XMLHttpRequest");
else
return xmlHttp;
}
function process()
{
if(xmlHttp)
{
try
{
var data1 = document.getElementById("input_1").value;
var data2 = document.getElementById("input_2").value;
var send_post="data1=" + data1 + "&data2=" + data2;
xmlHttp.open("POST","form.php",true);
xmlHttp.onreadystatechange=handleRequestStateChange;
xmlHttp.send(send_post);
}
catch(e)
{
alert("could not connect"+e.toString());
}
}
}
function handleRequestStateChange()
{
myDiv = document.getElementById("myDivElement");
if (xmlHttp.readyState==1)
{
myDiv.innerHTML += "query state 1(sending)<br />";
}
else if(xmlHttp.readyState==2)
{
myDiv.innerHTML += "query state 2(sended)<br />";
}
else if(xmlHttp.readyState==3)
{
myDiv.innerHTML += "query state 3(exchanging)<br />";
}
else if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
try
{
response=xmlHttp.responseText;
myDiv.innerHTML += "query state 4(completed).Server ansver: <br/>";
myDiv.innerHTML +=response;
}
catch(e)
{
alert("error of reading"+ e.toString());
}
}
else
{
alert("problems fith connecting"+xmlHttp.statusText);
}
}
}
index.php
--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Untitled Document</title>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<div id="myDivElement" /><br>
<input type="text" id="input_1" />
<input type="text" id="input_2" />
<input type="button" class="button" value=" Отправить форму " onclick="process();" />
</body>
</html>
form.php
---
<?php
if (isset($_POST['data1']))
$data1 = $_POST['data1'];
if (isset($_POST['data2']))
$data2 = $_POST['data2'];
echo $data1;
echo "<br>";
echo $data2;
?>