问题
I have a simple data entry tool on my Sheet that's an HTML form and then it runs through the fields in the form and posts them to the sheet. The utility works absolutely fine on my home computer. I noticed when a colleague tried it, it failed. I checked his console and there was an uncaught error. I tried the utility on my work computer and it also failed to push the values to the sheet. Almost like there is some type of issue with the google.script.run function? I have had it work for others on different networks. Attached is what it throws in the Chrome console. Not a very descriptive or useful error. I don't get this on my home computer.
My JavaScript:
<script>
// Prevent forms from submitting.
function preventFormSubmit() {
const forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
});
}
}
window.addEventListener('load', preventFormSubmit);
function handleFormSubmit(formObject) {
$("#formType").val($('title').text());
google.script.run.processForm(formObject);
$(".selectpicker").val("default"); // Reset select
$(".selectpicker").selectpicker("refresh"); // Refresh select
$("input").val(""); // Reset input values
$("textarea").val(""); // Reset input values
$("#waiver").parents().eq(1).css({ display: "none" });
if ($('title').text() === "PT Credit") {
var table = $("#credit_table")
table.parent().css({ display: "none" });
table.empty();
}
}
</script>
回答1:
Check your Apps Script Executions
After some experimenting I have found that whenever I had an uncaught
error in the client console, it was always because one of the server side Apps Script functions were failing.
Go to script.google.com > My Executions
Or to your specific project, the executions page:
Seeing as the error only appears on another system, it is likely to be account related. Though there should be more info in the executions page as to why it failed.
来源:https://stackoverflow.com/questions/66038410/google-apps-script-uncaught-error-in-chrome-console