0

I have to send the XML data from aspx using POST method and receive the parameters in another Aspx file.

I have stored the XML data in xmlValidator named Javascript variable. I tried with the following code but it didn't work for me:

For sending I wrote: validator.aspx

<script type = "text/javascript">
    function submit_a() {
        $.post("../All.aspx", { "data": validatorXML }, function (result) {
         alert(result);
        });
 }
</script>

And at the receiving point i.e. in All.aspx page I wrote: (read from blog)

<%@ Page Language="C#" AutoEventWireup="true" %>
 <%
   NameValueCollection nvc = Request.Form;
     Response.Write(nvc["data"]); //Here i have to call a method written in a .cs file
  // which return some data and print in `validator.aspx`
%>

But it prints nothing. What is the problem?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Amit Pal
  • 10,604
  • 26
  • 80
  • 160
  • Have you sniffed it through Firebug, F12 etc? – Humberto Aug 21 '12 at 21:07
  • 1
    where do you expect to write that down ? `Response.Write` - you call this using ajax. And this `alert(Done!);` must be `alert("Done!");` – Aristos Aug 21 '12 at 21:09
  • I have a problem, I mean i send the post request but how should i know that the data are received at the other site? – Amit Pal Aug 21 '12 at 21:10
  • @Aristos Done , On All.aspx page – Amit Pal Aug 21 '12 at 21:13
  • @AmitPal The ajax call is return what you write there on the `result`, then you get the result and you write it down somewhere to your page... eg try `alert(result);` – Aristos Aug 21 '12 at 21:16
  • @Aristos : Thanks that is exactly what i want, but still it didn't work. Code has updated – Amit Pal Aug 21 '12 at 21:19
  • First try this `Response.Write(Request.Form);` to see all posted data. The try to see if the other site page reject the post because aspx have a validation check to avoid hacks. – Aristos Aug 21 '12 at 21:25
  • NOthing happend @Aristos – Amit Pal Aug 21 '12 at 21:27
  • make some trace, debug it.... step on it.... – Aristos Aug 21 '12 at 21:29
  • @Aristos I just have one doubt. Is this the right syntax Response.Write(nvc["data"]); . I read this question and it is giving id instead of data. I mean i don't have so much idea of ASP http://stackoverflow.com/questions/5646720/asp-net-c-sharp-cant-read-posted-form-element – Amit Pal Aug 21 '12 at 21:32
  • Yes I do not see any other error - as I say you try to use the `Response.Write(Request.Form);` – Aristos Aug 21 '12 at 23:43

1 Answers1

0

Read it.

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx

Ashirvad
  • 2,367
  • 1
  • 16
  • 20