473,671 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX Redirect

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

Sep 7 '06 #1
7 31949
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.locati on 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
2452
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 redirected? this situation happen when some urls are only accesible when you are logged (i mean you have session) and if you losed session you are usually redirect to other page. But I don't know is it possible to check that my call was redirect....
5
2209
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 parts of your page. But in my application there are situation when I first notice on the server -- so AFTER sending an AJAX request -- that I have to update the complete page instead of only some parts. And what do I do now???
1
1905
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
1183
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 advance.
1
2210
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 beneath -------------------------------------------------------------------------------------------------- Sys.WebForms,PageRequestManagerParsesErrorExceptio n: The message received from the server could be parsed. Common causes for this error are...
5
3681
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 happening is the new page is being embedded into the login page, and I dont want that. ............................. if ($rowcount==0){ echo "<p>Wrong Username or Password Dufus</p>"; }
2
2349
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 have tried onasyncpostbackerror method but it is not even hitting the code behind. Because the server does try to redirect to login page we get the parser error(below) as it is trying to parse the login page in the background.
1
3954
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 ImageButton's click event contains the following code: Response.Redirect("ProductCatalog.aspx") The ProductCatalog.aspx page may take several seconds to load, so I wish to add an UpdateProgress to show the user "Loading...". I've added the...
1
2519
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 : - checked my web.config (copied below) - re-installed the ajax.net extensions - ran aspnet_regiis my application
0
8402
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8825
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7445
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.