<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pr_peremennya.aspx.cs" Inherits="pr_peremennya" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<title></title>
<script type="text/javascript">
function get_var() {
var x = "12";
var y = "14"
var params = 'x=' + encodeURIComponent(x) + '&y=' + encodeURIComponent(y);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "pr_peremennya.aspx", true);
xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.setRequestHeader('Connection', 'close');
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('Form1').innerHTML = xmlhttp.responseText;
// document.getElementById('answer').innerHTML = params;
//alert(xmlhttp.responseText);
}
};
xmlhttp.send(params);
}
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("the-button").addEventListener("click", get_var);
});
</script>
</head>
<body>
<div id="container">
<button id="the-button" >Click me</button>
<form id="Form1" runat = "server">
<%
string rd = Request["x"];
string rd1 = Request["y"];
Response.Write(rd+"qq "+rd1);
%>
</form>
</div>
</body>
</html> |