1

我有一个从 cgi 应用程序填充的 html 页面。现在,当我通过表单对我的 html 页面进行更改时

<form action="/cgi-bin/Lib.exe" method=POST name="checks" ID="Form2">

它把我从
http://localhost/index.html
带到
http://localhost/cgi-bin/Lib.exe,CGI 输出一些我放在那里的调试行。然后我必须手动返回索引以查看它的更新。

当 html 表单向 cgi 应用程序发送请求时,CGi 应用程序对数据库进行更新并重写索引 html。我如何留在索引页面上并查看它的更新?(我正在运行轻量级 GoAhead Web 服务器、C 中的 CGI 和 html、JS)

谢谢。

4

2 回答 2

6

您可以从 CGI 脚本发送 302 状态代码,它将用户的浏览器重定向到/index.html.

基本上,让 CGI 脚本吐出这个:

HTTP/1.1 302 Found
Location: /index.html

 
于 2009-01-15T23:24:37.830 回答
2

您基本上是在问“我如何使用 AJAX”。我建议使用图书馆。在 JQuery 中,它看起来像:

$.ajax({
   type: "POST",
   url:  "/cgi-bin/Lib.exe",
   data: "foo=bar&spoo=fleem",
   success: function(html){
      $("#results").append(html);
   }
});
于 2009-01-15T23:14:50.737 回答