0
function sendRequestToDelicious()
{
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
var url = "http://localhost:52271/WebForm1.aspx";
var params = "q=hello";
xmlhttp.open("POST", url, true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.send(params);
}
在我的ASP.NET应用程序中,我正在从page_load事件读取流,但没有收到数据。我究竟做错了什么?不接收来自http输入流的数据
C#代码在ASP.NET:
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
StreamReader reader = new StreamReader(Page.Request.InputStream);
String data = reader.ReadToEnd();
}
...
我不实际需要发送数据时,它只是一个试验。我试图做的就是发送一个请求,从我的Firefox,插件(我的asp.net应用程序),当点击一个按钮,查看建议。您给我的帖子涉及发送帖子数据,没有收到帖子,或者我误解了? – michelle 2011-04-26 15:47:28
它兼具两种功能。首先发送数据,然后收到响应。如果您正试图通过Firebug查看AJAX交通,确保你去XHR选项卡。 – 2011-04-26 15:54:01
提琴手有滚动您自己的请求,发送到服务器,然后看到什么回来优秀的能力。你可能想尝试使用它。 http://www.fiddler2.com/fiddler2/ – 2011-04-26 16:00:28