我看见了
this post
HTML
打开一个对话框,在google电子表格上有一个插件,我正在使用
JBDC
我从多个查询中加载一些数据
MYSQL
数据库,我也有一个搜索栏来搜索数据库中的数据,在未来,我想我的HTML自动显示各种数据库值取决于我的选择
HTML格式
我已经尝试了很多可以用伪代码展示的东西。
-
所以这是我的
GS公司
文件
function firstFunc()
{
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
//do my thing
return (datas);
}
function secondFunc()
{
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
//do my thing
return (datas);
}
function thirdFunc()
{
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
//do my thing
return (datas);
}
然后我的
HTML格式
<script>
var onSuccessFirst = function (data){
//update my HTML with data
}
var onSuccessSecond = function (data){
//update my HTML with data
}
var onSuccessThird = function (data){
//update my HTML with data
}
google.script.run.withSuccessHandler(onSuccessFirst).firstFunc();
google.script.run.withSuccessHandler(onSuccessSecond).secondFunc();
google.script.run.withSuccessHandler(onSuccessThird).thirdFunc();
</script>
-
尝试将连接从服务器传递到客户端,然后再传递回服务器:
function getConnection()
{
return (Jdbc.getConnection(dbUrl, user, userPwd););
}
function firstFunc(conn)
{
conn...
//do my thing
return (datas);
}
function secondFunc(conn)
{
conn...
//do my thing
return (datas);
}
function thirdFunc(conn)
{
conn...
//do my thing
return (datas);
}
HTML格式
<script>
var onSuccessFirst = function (data){
//update my HTML with data
}
var onSuccessSecond = function (data){
//update my HTML with data
}
var onSuccessThird = function (data){
//update my HTML with data
}
var onSuccessConnection = function(conn)
{
google.script.run.withSuccessHandler(onSuccessFirst).firstFunc(conn);
google.script.run.withSuccessHandler(onSuccessSecond).secondFunc(conn);
google.script.run.withSuccessHandler(onSuccessThird).thirdFunc(conn);
}
google.script.run.withSuccessHandler(onSuccessConnection).getConnection();
</script>
但是在这里
conn
null
.
我也有很多查询发送时,我的输入(搜索栏)是
onchange
我使用第一种方法,它可以工作,除了它不允许快速键入,因为它增加了每个字符的连接请求。
我能做什么?