Home > Back-end >  Error while using HTML in appscript. Error: Net state changed from IDLE to BUSY
Error while using HTML in appscript. Error: Net state changed from IDLE to BUSY

Time:03-14

I have written an HTML file, in the same when I try to pass data to a .gs file in order to print or console.log then it doesn't give the log in the output of the console and instead, it reflects these statements in the console:

Net state changed from IDLE to BUSY

Net state changed from BUSY to IDLE

Attaching the code UI, HTML file, and .gs file below for reference.

HTML output: enter image description here

HTML file:

<!DOCTYPE html>
<html>
    <head>
      <!--Import Google Icon Font-->
      <link href="https://fonts.googleapis.com/icon?family=Material Icons" rel="stylesheet">
       <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

      <!--Let browser know website is optimized for mobile-->
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    </head>

    <body>

      <div >

        <div >  
          <div >
            <i >insert_link</i>
            <input id="zz" type="text" >
            <label for="zz">Insert Text</label>
          </div>
         


          <div >
            
            <button  id="btn">Submit
              <i >send</i>
            </button>
        
          </div>
        </div>

      </div>

      <!-- Compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    <script src="testBox.gs"></script>
    <script>
      var gSheetUrl = document.getElementById("zz");

      document.getElementById("btn").addEventListener("click",abc);

      function abc(){
        console.log("inside abc");
        var data = {
          zzz: zz.value
        }

        google.script.run.getData(data);
      }

    </script>
    </body>
  </html>

.gs file:

function openIndexDialog() {
  
  var template = HtmlService.createTemplateFromFile("indexDialog");

  var html = template.evaluate().setHeight(450).setWidth(600);

  SlidesApp.getUi().showModalDialog(html,"Demo App");

}

function getData(data){
  console.log(data)
  console.log("data logged")
}

Console output:

enter image description here

Main Problem: Not able to print data when passed through getData(data)

CodePudding user response:

Those are not error messages, they are information logs about the server- client communication .

Every time that your client code call a server-side function using google.script.run there will be a Net state changed from IDLE to BUSY log and when the server-side function ends will be a Net state changed from BUSY to IDLE.

Regarding

Main Problem: Not able to print data when passed through getData(data)

If you want to print data on the client side, you have use console.log on the client-side, not on the server-side. Logs printed from the server side can be found in the executions page.

Related

  • Related