|
|
|
| Ничего не понимаю, когда-то ж вроде у меня получалось... У меня ИЕ....
index.htm
<html>
<head>
<script>
function my_ajax(URL,data)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
req.onreadystatechange = verify;
req.open("POST", URL, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=windows-1251");
req.send(data);
}
else if (window.ActiveXObject)
{
req = new ActiveXObject("Msxml2.XMLHTTP");
if (req) {
req.onreadystatechange = verify;
req.open("POST", URL, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
req.send(data);
}
}
}
function verify()
{
if (req.readyState == 4)
{ if (req.status == 200){processReqChange();}else alert("Не удалось получить данные:\n" +req.statusText
+' '+req.status+url);}
}
function processReqChange()
{
var resp = req.responseText;
document.getElementById('response').innerText="";
document.getElementById('response').innerText=resp;
}
function post()
{
var params =encodeURIComponent(document.getElementById('to_post').innerText);
my_ajax('request.php',params);
}
</script>
</head>
<body>
To post: <br/>
<input type="text" id="to_post"><br/>
<input type="button" onclick="post()" value="POST"><br/>
RESPONSE: <br/>
<input type="text" id="response">
</body>
</html>
|
request.php
<?
header("Content-type: text/plain; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo $_POST['params'];
?>
|
| |
|
|