Google script web app goes blank page after submit

后端 未结 2 1441
南旧
南旧 2021-01-27 04:48

I have a google script web app with input fields. I would like all of those fields is input required if user want to submit data. Therefore, I used \"required\" attribute and ca

相关标签:
2条回答
  • 2021-01-27 05:16

    Issue:

    preventDefault is not called onSubmit. Hence the form is posted to the sandboxed user iframe inside the web-app.

    Solution:

    Call preventDefault.

    Snippet:

    e.preventDefault();//modified
    

    Note:

    Make sure #hora's val() is not a date object as date objects are illegal as parameters and cannot be passed from client to server.

    0 讨论(0)
  • 2021-01-27 05:20

    I think these two functions should be separated:

    function callEvent() {
      var cellSelectedValue = $('#cellName').val();
      google.script.run.withSuccessHandler(machineOption).machineNameByCell(cellSelectedValue);
      var machineNameDropBoxhtml = '';
    
      function machineOption(data) {
        try {
          for (var i = 0; i < data.machineNameArray.length; i++) {
            machineNameDropBoxhtml += '<option value=' + data.machineNameArray[i] + '>' + data.machineNameArray[i] + '</option>';
          }
          $('#machineName').html(machineNameDropBoxhtml);
          $('#machineName').formSelect();
        } catch (error) {
          alert(error);
        }
      }
    }
    

    Like this:

    function callEvent() {
      var cellSelectedValue = $('#cellName').val();
      google.script.run
      .withSuccessHandler(machineOption)
      .machineNameByCell(cellSelectedValue);
      var machineNameDropBoxhtml = '';
    }
    
    function machineOption(data) {
      try {
        for (var i = 0; i < data.machineNameArray.length; i++) {
          machineNameDropBoxhtml += '<option value=' + data.machineNameArray[i] + '>' + data.machineNameArray[i] + '</option>';
        }
        $('#machineName').html(machineNameDropBoxhtml);
        $('#machineName').formSelect();
      } catch (error) {
        alert(error);
      }
    }
    
    0 讨论(0)
提交回复
热议问题