views:

29

answers:

2

Hi, I need to pass huge amount of data to server without page loading i have code

enter code here
                var GlType = "<%=GlType %>";
                var pageUrl = "SelectAccount.aspx?callback=true&AccountList=" +accountList +"&AnalysisDate="+analysisDate+"&GlType="+GlType;
                if (window.XMLHttpRequest)
                 {
                      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 thsi..

A: 

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).

Evan Trimboli
thanks for u'r reply How to get a data in server side post some code sample in c sharp
Gulshan
@Evan Trimboli; Yes I too agree with you.
Muneer
@Koen has posted a sample of how to retrieve the data.
Evan Trimboli
+1  A: 

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.

Koen
How to retrive data in server please paste some code in c sharp.
Gulshan
Thanks a lot for u'r answer..
Gulshan

related questions