View Full Version : Redirecting client-side based on response from server

04-21-2005, 09:55 PM
Please can someone remind me how to do this? I need the user post some data to a CGI program which returns HTML. Based on the data returned, I may need to redirect the user. I've done this before but forgotten where and how! I'm sure I used a Javascript function on the results page. It needs to read the response and act before the initial response is displayed.

Any pointers much appreciated!


04-22-2005, 05:28 AM
Let the CGI ouput this meta tag inside the <head> tag based on the data returned.

<meta http-equiv="refresh" content="0; theURL" />

04-23-2005, 12:19 PM
Thanks for the reply. Perhaps I should explain the problem better.

I have a form for the user to submit a query to a CGI program. The CGI is not mine and I dont have the source, so I can't change it. The CGI program will either return the data that I want to display or an error. I want to trap the error before it is displayed and redirect the user to a different form.

I've done something similar to this before. I think I sent the form data to another page instead of directly to the CGI. I think I then had a javascript function which called the CGI program and looked at the response before displaying it. If the response was an error it called a different page rather than displaying the data.

Unfortunately I've forgotten how I called the CGI and examined the response without displaying it.