[英]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 調用)。
讓它發揮作用所需要做的就是:
一些有用的谷歌點擊: Struts 和 Ajax 一起工作, 使用 Javascript 即時更改內容。
你有正確的方向,現在 go 並進行最后的潤色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.