如何操纵和重定向 google 表单操作,而不用 javascript and/or jquery 向用户显示

How to manipulate and redirect google form action without having that shown to the user with javascript and/or jquery

我有一个 google 表格,我将其嵌入我的网站并更改 css,因此它可以 post 到 google 张。

<form action="https://docs.google.com/forms/d/FormID/formResponse" method="POST" target="_self" onsubmit="" role="form">
  <table>
    <thead>
      <tr>
        <th>Friends name</th>
        <th>Email</th>
      </tr>
    </thead>
  <tbody>

  <tr>
    <td>
      <div class="form-group">
        <input type="text" name="entry.ID" value="" id="entry_ID" class="form-control" dir="auto" aria-label="Name  " title="">
      </div>
    </td>

    <div>
      <input type="submit" name="submit" value="Submit" id="button-submit" class="btn btn-primary btn-block">
    </div>
</form>`

现在,如果您注意到这里的按钮是一个输入,我想做的是将 post 表格保持在 google 工作表的正常状态,而不向用户显示任何内容,我想将用户重定向到不同的成功消息页面或某些表明 posting 有效的 jquery 操作。 我希望我足够具体,google 没有帮助,我找不到类似的东西, ps:我删除了大部分不相关的代码和输入。

您不能保持它正常 posting 并劫持来自服务器的响应。但是您可以使用 AJAX post 数据并处理响应:

$( "form" ).on( "submit", function( event ) {
  var $t = $( this ),
      params = $t.serialize(),
      url = $t.prop('action');

  event.preventDefault();

  $.post( url , params )
     .done(function() {
        console.log( "success" );
        window.location.href = "success.html");
     })
     .fail(function() {
        console.log( "error" );
        window.location.href = "error.html");
     });
});