I am trying to figure out server/client data type matching. In the html with javascript, form itself is supposed to be sent to google code.gs.
<body>
<form id='form1'>
<div>
....buttons and input texts...
</div>
-- here the last button's onclick I call lSubmit(this.parentNode)
<button type="button"
onclick="lSubmit(this.parentNode)"
id=btn>click</button>
</form>
<script>
var x = $("#output");
function lSubmit(formObj) {
x.html('Wait until verified.');
google.script.run
.withSuccessHandler(onSuccess)
.withFailureHandler(onFailure1)
.chkForm(formObj);
}
</script>
As I was not well aware of parentNode, it took whole day for me to figure out what my mistake was. Because I used 'div' after form, lSubmit was taking div.
My question is,
code.gs
function chkForm(formObj) {
Logger.log("chkForm in Code.js called. id: %s",formObj.uname);
return 'You entered id' + formObj.uname + ' to login...';
}
As I was sending div, but chkForm wants to receive form, isn't there supposed to be some error code returned? But in the server log doesn't say 'undefined' or object type or formObj.uname doesn't exist kind of sorts. Nor end result in javascript withSuccessHandler, withFailureHandler. Actually, lSubmit wasn't called I think. Because I didn't see the comment Wait until verified.
Just like some typo, this time was too difficult what went wrong.
Last question I asked was also ended up wrong in data handling where server returns date but javascript can't handle. But in that case, withFailureHandler worked. So it was figured out quickly. However, now, what should I add to where so that I can catch that there is an error in data type mismatch between server and client? Like in this case, that client is sending wrong data?
Is it javascript refusing to run as it saw mismatching?