473,418 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

AJAX Redirect

ses
How do i implement server side redirect when the request was submitted
using AJAX?

Sep 7 '06 #1
7 31930
You don't. That's why you use Ajax in the first place. If your request
results in a need for a new page load then you've missed the entire
point.

Sep 7 '06 #2
ses wrote:
How do i implement server side redirect when the request was submitted
using AJAX?
Same way as normal (and then XMLHttpRequest will make another request to the
new URL and get the data from there).

A redirect response to an XMLHttpRequest cannot directly change the URL that
user is viewing (since the request that the page was returned from is not
the one being redirected).

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 7 '06 #3

Tom Cole wrote:
You don't. That's why you use Ajax in the first place. If your request
results in a need for a new page load then you've missed the entire
point.
That being said, you'll have to perform the redirect client side in the
callback handler for the XmlHttpRequest. You can do this by setting the
document.location value.

Sep 7 '06 #4
ses
I found this strage as the W3C XMlHttpRequest specification says that
the redirect should be handle as normal.

So I created a Page that accepts AJAX Requests and sends back a status
of 302 think it would redirect the page put it did. So while i take you
point but i was programming to specification.

Sep 7 '06 #5
ses wrote:
I found this strage
You find what strange? Please quote.
as the W3C XMlHttpRequest specification says that
the redirect should be handle as normal.
And it is handled as normal. A redirect means "The resource you requested
can actually be found here", not "Point the main window of the browser to
this other URL".

If the resource being requested is supposed to be handled by an
XMLHttpRequest object, then the resource at the other end of the redirect
will be.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 7 '06 #6
ses

W3C states:

If the response is an HTTP redirect (status code 301, 302, 303 or 307),
then it MUST be transparently followed (unless it violates security,
infinite loop precautions or the scheme isn't supported). Note that
HTTP [RFC2616] places requirements on UAs regarding the preservation
of the request method during redirects, and also requires users to be
notified of certain kinds of automatic redirections.

I am slowly understanding so you are saying if I want the request to be
handle by another page PageB.aspx it would pass all the parameters. But
not change the window location.

Sep 8 '06 #7
ses wrote:
I am slowly understanding so you are saying if I want the request to be
handle by another page PageB.aspx it would pass all the parameters. But
not change the window location.
What happens:

XMLHttpRequest requests PageA.
The server returns a redirect response.
XMLHttpRequest requests PageB and handles it.

What doesn't happen:

XMLHttpRequest requests PageA.
The server returns a redirect response.
The main browser page viewing thingy[1] requests PageB and handles it.
[1] &trade;

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Grzegorz Smith | last post by:
Hi everyone. Does anyone know is it possible to check if ajax call was redirect? i mean I connect by Ajax to one URL but I'm redirected to other url. Is there a way to check that my request was...
5
by: Martin | last post by:
Hello NG, I've been doing some AJAX for a few weeks now. The basics worked fine so far, but now I've got the following problem which I can't solve: With AJAX you typically update/replace only...
1
kamill
by: kamill | last post by:
I am strange for Ajax and i need to redirect a page threw Ajax like Java script(window.location.href="desiredlocation.php". Is there any script in Ajax. Thanking in advance kamill
2
by: archana | last post by:
Hi all, I am new to AJAX technology. can anyone provide me some link using which i can lean AJAX?. Or give just overall idea about AJAX? any help will be truely appreciated. Thanks in...
1
by: kmithu | last post by:
I am working on Asp.Net2.0 on which i have used ajax. I am well aware that Response.Write() is not supported by AJAX but what about Response.Redirect()? The error which i am getting is written...
5
by: Mike | last post by:
Hello, I have a Login page that checks a Db for a Un and Pw using ajax. If the Login is incorrect, they just get a embedded message. If it is correct, I want to redirect COMPLETLY. Whats...
2
by: Angel666 | last post by:
We are using forms authenication with AJAX update control panels. We get various results but no redirect when the user has timed out and is no longer authenicated and does a asyncpostback. We...
1
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it possible to display an UpdateProgress control when an event calling Response.Redirect is executed? I have a simple webform with an ImageButton and an UpdateProgress control. My...
1
by: Yan | last post by:
Hi, I'm apparently far from being the 1st one to meet this error... My asp.net ajax page requires ScriptManager.axd but gets a 404. following a lot of "This is how I solved it" posts, I : -...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.