Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can I run a CGI script without returning a new page to the browser?

0
Posted

Can I run a CGI script without returning a new page to the browser?

0

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

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.