I'm trying to create a pop-up browswer in GAS. What I wanna do here is post some value to my local api and get response from it. My code below doesn't work as I meant to and it's stuck in the screen in the picture. Api doesn't get any request meaning post is not working successfully. Any advice will be appreciated.
if (cell_tick == true) {
var tick_row = cell_pos.getRow();
var date = new Date();
sheet.getRange(tick_row, date_column).setValue(date).setNumberFormat('yyyy/MM/dd H:mm:ss');
openTab()
function openTab() {
var js = "<script language='JavaScript'>\
function openWindow()\
{\
myWindow = window.open('about:blank','theWindow','width=400,height=400');\
}\
</script>\
<form method='POST' name='myForm' action='http://127.0.0.1:5000/' target='theWindow'>\
<input type='text'>\
<input type='button' onERASETHISClick='openWindow(); document.myForm.submit()' value='Open and after submit'>\
</form>;\
"
var html = HtmlService.createHtmlOutput(js)
//.setHeight(10)
//.setWidth(100);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}
}
CodePudding user response:
Thanks guys. I changed onERASETHISClick to onClick and it did as I expected.
CodePudding user response:
Your form is in an iFrame, it basically exists in the internet on some server somewhere. It cannot post to localhost because that address is not public, it is local to your router. A good way to start is to read how client (the form) and the server (the app) can communicate with each other here.

