Can I run a CGI script without returning a new page to the browser?
Yes, but think carefully first: How are your readers going to know that their “submit” has succeeded? They may hit ‘submit’ many times! The correct solution according to the HTTP specification is to return HTTP status code 204. As an NPH script, this would be: #!/bin/sh # do processing (or launch it as background job) echo “HTTP/1.0 204 No Change” echo (as non-NPH, you’d simply replace HTTP/1.0 with the Status: CGI header). Alan J Flavell has pointed out that this will fail with certain popular browsers, and suggests a workaround to accommodate them: [ May 1998 update[1]: I’m deleting Alan’s suggestion, because the problem is mainly of historical interest, and the workaround is no longer recommended. See his page for a detailed survey and recommendations. ] His survey is at http://web.archive.org/web/20060504050418/ppewww.ph.gla.ac.uk/~flavell/www/status204/results.html [1] With apologies to Alan for having left it in so long.
Related Questions
- If I use an auto-configuration script in my client Internet Explorer web browser, I cannot get to the login page of the ProCurve 700wl product. Why?
- When I try to run a CGI script from my browser, it tries to download a file of type "application/x-perl" instead. What gives?
- Can I run a CGI script without returning a new page to the browser?