Javascript cgi脚本多次发送表单数据,每次刷新一次

Javascript cgi脚本多次发送表单数据,每次刷新一次,javascript,python,forms,cgi,Javascript,Python,Forms,Cgi,我正在尝试使用带有smtplib和imaplib的python cgi编写自己的Web邮件应用程序。当我点击发送表单上的“发送”按钮时,电子邮件会被发送,但是,每次刷新之后,邮件都会再次发送。页面cgi脚本每两分钟通过javascript自动刷新一次: <script language="javascript"> window.setInterval('refresh()', 180000); function refresh() { /

我正在尝试使用带有smtplib和imaplib的python cgi编写自己的Web邮件应用程序。当我点击发送表单上的“发送”按钮时,电子邮件会被发送,但是,每次刷新之后,邮件都会再次发送。页面cgi脚本每两分钟通过javascript自动刷新一次:

  <script language="javascript">

    window.setInterval('refresh()', 180000);

    function refresh() 
    {
      // this checks to see which tab is selected, page is refreshed only if compose tab is not selected
      elList = document.getElementsByTagName("a");
      for (i = 0; i < elList.length; i++)
      { 
        if (elList[i].className === 'tab active') 
        {
          var activeTab = elList[i].innerHTML;
        }
      }

      if (activeTab.indexOf("Unread") >= 0)
      {
         window.location.reload(true);
      }

    } 
  </script> 
我尝试在页眉标记中使用javascript重置表单,但这不起作用:

<script language="javascript">
  Form.reset('send');  // reset send form so email is not sent again
</script>
为完整起见,以下是表格定义:

  <form name="send" action="/cgi-bin/myemail.py" method="post" >
  <table id="example" class="compose" >
    <tr>
      <td><input type="submit" value="To:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_to" size="90"></td><td><input type="submit" name="send" value="SEND" style="height: 1.95em; width: 12em"></td> 
    </tr>
    <tr>
      <td><input type="submit" value="Cc:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_cc" size="90"></td> <td><input type="submit" name="send" value="SAVE" style="height: 1.95em; width: 12em"></td>
    </tr>
    <tr>
      <td><input type="submit" value="Bcc:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_bcc" size="90"></td> <td><input type="submit" name="send" value="DELETE" style="height: 1.95em; width: 12em"></td>
    </tr>
    <tr>
      <td><input type="submit" value="Subj:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_subj" size="90"></td> <td><input type="submit" name="send" size="200" value="ATTACH" style="height: 1.95em; width: 12em"></td> 
    </tr>
    <tr>
      <td colspan="3">
        <!-- <td colspan="3"> <div id="result" class="body" style="background-color:#000000"></div></td> -->
        <textarea name="send_body" cols="118" rows="23"> </textarea>
      </td>
    </tr>
  </table>
  </form>

如何防止此表单数据被多次读取?谢谢。

您是使用POST还是GET发送表单数据?@Lee Taylor,如果我错了,请纠正我,但表单标记中定义为method=postdim,是的,正确。我今天显然不识字!
  <form name="send" action="/cgi-bin/myemail.py" method="post" >
  <table id="example" class="compose" >
    <tr>
      <td><input type="submit" value="To:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_to" size="90"></td><td><input type="submit" name="send" value="SEND" style="height: 1.95em; width: 12em"></td> 
    </tr>
    <tr>
      <td><input type="submit" value="Cc:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_cc" size="90"></td> <td><input type="submit" name="send" value="SAVE" style="height: 1.95em; width: 12em"></td>
    </tr>
    <tr>
      <td><input type="submit" value="Bcc:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_bcc" size="90"></td> <td><input type="submit" name="send" value="DELETE" style="height: 1.95em; width: 12em"></td>
    </tr>
    <tr>
      <td><input type="submit" value="Subj:" style="height: 1.95em; width: 4em"></td><td><input type="text" name="send_subj" size="90"></td> <td><input type="submit" name="send" size="200" value="ATTACH" style="height: 1.95em; width: 12em"></td> 
    </tr>
    <tr>
      <td colspan="3">
        <!-- <td colspan="3"> <div id="result" class="body" style="background-color:#000000"></div></td> -->
        <textarea name="send_body" cols="118" rows="23"> </textarea>
      </td>
    </tr>
  </table>
  </form>