开发者

Need to post large amount of data using xmlHttprequest

I need to pass huge amount of data to server without page loading. I have this code:

var GlType = "<%=GlType %>";
var pageUrl = "SelectAccount.aspx?callback=true&AccountList=" +accountList +"&AnalysisDate="+analysisDate+"&GlType="+GlType;
if (window.XMLHttpRequest)
 {
 开发者_StackOverflow社区     var xmlRequest = new XMLHttpRequest();
 }
else
 {
      var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
 }
xmlRequest.open("POST", pageUrl, true);
xmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
xmlRequest.send(null);

I am have passed using query string its exceeded the maximum Length of query string. Help me on this..


Since you're already using the POST method, you can pass data in the body.

xmlRequest.send("Field1=abc&Field2=def");

You can retrieve the data on the server, e.g. in ASP.NET:

if (Page.Request.Form["Field1"] == "abc") ...

For GET method you can only use the query string for transferring data.


You're sending the request via post, but putting everything in the query string!

Instead, you should send the data as the body of the request (passed to the send method).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜