使用beego框架与JavaScript配合使用。

huangapple go评论68阅读模式
英文:

Using javascript with beego

问题

我是你的中文翻译助手,以下是翻译好的内容:

我对beego和golang还不熟悉。我正在使用beego开发一个Web应用程序。我实在找不到如何在beego中使用JavaScript。

例如:

在某个页面上,我要显示来自所有部门的所有用户的姓名。现在,我在该页面上有一个下拉框,它将显示数据库中存在的各个部门。现在,当我从下拉列表中选择一个部门时,我希望只显示属于该部门的用户。

我可以使用JavaScript获取所选部门的索引值,但是如何在控制器中使用这个索引值,并在数据库查询中使用它呢?

英文:

I am new to beego and golang. I am developing a web application in beego. I am honestly not able to find out how to use javascript with beego.

For example:

On a particular page i am showing all users name from all department. Now i have a drop down box in that page that will show the various department present in database. Now when i select one of that department from drop down list i want to show only users belonging to that department.

I can get the index value of selected department using javascript but how to use this index in controller to use it in database query?

答案1

得分: 1

基本上,你只需要使用以下代码来获取请求参数并进行逻辑处理,然后返回结果:

param := c.GetString("param") // 获取请求参数 "param"

对于beego框架,没有指定的JavaScript代码。

这里是演示代码的链接:https://gist.github.com/lei-cao/a4004ccab8d528df575b

英文:

Basically you only need to use

	param := c.GetString("param") // Get the request parameter "param"

to get the request parameter and do you logic and the return the result.

No specified Javascript code for beego.

Here is the demo code https://gist.github.com/lei-cao/a4004ccab8d528df575b

huangapple
  • 本文由 发表于 2014年12月2日 04:23:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/27236614.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定