Ajax call in google spreadsheet (POST)

Viewed 16

I have a button which calculates the time (in millisecond) between two button clicks

function stopButton() {
        if (startTime) {
          var endTime = Date.now();
          var difference = endTime - startTime;
          alert("Reaction time: " + difference + " ms");
          startTime = null;
        }
      }

I want to store this value inside google sheet as soon as the click is triggered Here, i am using ajax

$(document).ready(function () {
        $("#yes").click(function (e) {
          e.preventDefault();
          $.ajax({
            type: "POST",
            url: "https://script.google.com/macros/s/<somecode>/exec",
            success: function (result) {
              alert("ok");
            },
            error: function (result) {
              alert("error");
            },
          });
        });
      });
<button id="yes" class="action-btn" name="yes">
            <i class="fa fa-yes">Yes</i>
          </button>

I want to store the value which calculates the time between two button click inside google spreadsheet. Is there any way to do that. I am very new to javascript. Any kind of help would be greatly appreciated.

Thank you

0 Answers
Related