HttpRequest, HttpResponse and HttpConfusion

I admit I got kinda confused with Http requests and responses, so I’ll begin by presenting my problem.I made a webpage that takes user input, processes it and uses XMLHttpRequest POST to send the processed data to another page and display said data into said page.Now, I can form the XMLHttpRequest using POST just fine, as well …

via Asp.Net Developed Tutorials » Search Results » ajax:

HttpRequest, HttpResponse and HttpConfusion

I admit I got kinda confused with Http requests and responses, so I’ll begin by presenting my problem.
I made a webpage that takes user input, processes it and uses XMLHttpRequest POST to send the processed data to another page and display said data into said page.
Now, I can form the XMLHttpRequest using POST just fine, as well as successful redirection; but what I want to actually do is have the second page display the POSTed data.
How can I let the second page read and display the data encapsulated in the POST request in a successful redirection from the first page?
Here is my XMLHttpRequest code, in javascript:
var xmlhttp= new XMLHttpRequest()

xmlhttp.open(‘POST’,”Default2.aspx”,false);
xmlhttp.setRequestHeader(‘Content-Type’,
‘application/x-www-form-urlencoded’);
xmlhttp.setRequestHeader(“Connection”, “close”);

xmlhttp.onreadystatechange = function()
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
window.location = “Default2.aspx”;

}

xmlhttp.send(“”+x);I want to handle the POSTed data in the second page in javascript or ASP.NET.
………………………………….

It sounds like you shouldn’t be using AJAX / XMLHttpRequest at all. Just create a form that posts to the second page like normal, ie:



XMLHttpRequest is for getting server-side data from a different page/script and doing something with that data without leaving the current page. When you want to leave the current page you just use a form, as has been the standard for 15+ years.

For more info: HttpRequest, HttpResponse and HttpConfusion

Asp.Net Developed Tutorials » Search Results » ajax

HttpRequest, HttpResponse and HttpConfusion

Share this post:

Related Posts

Leave a Comment