本文介绍了如何从asp.net中的xmlhttprequest获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
This is my code in one asp page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PostRequestWithData.aspx.cs" Inherits="PostRequestWithData" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function LoadXMLDoc()
{
var xmlhtml;
if (window.XMLHttpRequest) {
xmlhtml = new XMLHttpRequest();
}
else {
xmlhtml = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhtml.onreadystatechange = function () {
if (xmlhtml.readyState == 4 && xmlhtml.status == 200)
{
document.getElementById("div1").innerHTML = xmlhtml.responseText;
}
};
var parameters = "fname=Henry&lname=Ford";
xmlhtml.open("POST", "demo_post2.aspx", true);
xmlhtml.setRequestHeader("Contenttype", "application/x-www-form-urlencoded");
xmlhtml.setRequestHeader("ContentLength", parameters.length);
xmlhtml.setRequestHeader("Connection", "close");
xmlhtml.send(parameters);
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button onclick="LoadXMLDoc();">Request data</button>
<div id="div1"></div>
</body>
</html>
</pre>
And This is perform page to get data from page 1
<pre lang="HTML">
<%@ Page Language="C#" AutoEventWireup="true"
<%
string fname = Request.Form["fname"];
string lname=Request.Form["lname"];
Response.Write("Hello " + fname+lname);
%>
</pre>
But perform page can't get data from page 1. Please help me !
推荐答案
DataTable s = new DataTable();
s.ReadXml(xml file)
s.ReadXmlSchema()
希望它的帮助
hope its helpes
这篇关于如何从asp.net中的xmlhttprequest获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!