繁体   English   中英

从 struts2 调用 ajax 来填充 div

[英]Calling ajax from struts2 to populate a div

I have a drop down and have a JavaScript function tied to the onchange event of the drop down.I need to call a action class with the drop down selected value and fetch data from database.I need pointers to call the action class from JavaScript and还传递下拉的选定值以触发 DB select 查询并更新 div 中存在的表而不刷新整个页面。

我的下拉

<s:select name="newQuestion.CertificationId" list="certificationList"
    listKey="certificationId" listValue="certificationName" headerKey=""
    headerValue="Select Certification" label="Certification Name"
    onchange="getQuestionsList(this.value)" />

Javascript function

function getQuestionsList(val) {
        alert("Here" + val);



    }

基本上,对于每个下拉选择的值,我需要对 DB 调用 ajax 来填充当前隐藏的 div。

你到底需要什么帮助? 据我了解,您已经弄清楚了(减去对 Struts 操作的 ajax 调用)。

让它发挥作用所需要做的就是:

  • 你需要什么 URL 调用 Struts 动作
  • 如何调用 Struts 动作
  • 如何使用 Javascript 更改 div 元素的内容

一些有用的谷歌点击: Struts 和 Ajax 一起工作使用 Javascript 即时更改内容

你有正确的方向,现在 go 并进行最后的润色。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM