我在加载对select
标签的响应时遇到问题。我正在尝试根据第一个更改选择框。
为此,我使用带有 jQuery Ajax 标签的 Struts 2。我想我有所有必需的东西,但响应没有标记到选项,但能够在浏览器的视图源的 JS 中看到结果。
下面是我用 JSP 编写的代码。
这是我的第一个选择框:
<div class="type-text">
<s:url id="remoteurl" action="getGlobalManufacturerJquery.action?mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=%{gameFileID}&gameFileName=%{gameFileName}&titleName=%{titleName}&titleID=%{titleID}"/>
<sj:select
href="%{remoteurl}"
formIds="TitleGameHandsetsForm"
id="manufacturerName%{titleGameFilemappingID}"
onChangeTopics="reloadsecondlist"
name="manufacturerName%{titleGameFilemappingID}"
list="%{manufacturers}"
listKey="%{globalManufacturer}"
listValue="%{globalManufacturer}"
emptyOption="true"
headerKey="-1"
headerValue="Select Global Manufacturer"
/>
</div>
下面是我的第二个选择框,它应该在第一个值上
<div class="type-text">
<s:url id="remoteurl" action="getGlobalModelJquery.action?mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=%{gameFileID}&gameFileName=%{gameFileName}&titleName=%{titleName}&titleID=%{titleID}"/>
<sj:select
id="globalModel%{titleGameFilemappingID}"
formIds="TitleGameHandsetsForm"
reloadTopics="reloadsecondlist"
name="modelFromSelect"
list="%{modelList}"
emptyOption="true"
headerKey="-1"
headerValue="Select Global Model"
/>
</div>
在 JSP 中没有可用的列表。但是服务器代码正在获得结果,我可以在 JS 的源代码中看到它无法附加到选择框的 JSP 中。
<select name="manufacturerName77" id="manufacturerName77">
<option value=""></option>
</select>
<script type='text/javascript'>
jQuery(document).ready(function () {
var options_manufacturerName77 = {};
options_manufacturerName77.datatype = "json";
options_manufacturerName77.type = 'select';
options_manufacturerName77.emptyoption = true;
options_manufacturerName77.headerkey = "-1";
options_manufacturerName77.headervalue = "Select Global Manufacturer";
**options_manufacturerName77.list = "[Acer, A Panda]";**
options_manufacturerName77.listkey = "Acer";
options_manufacturerName77.listvalue = "Acer";
options_manufacturerName77.jqueryaction = "select";
options_manufacturerName77.id = "manufacturerName77";
options_manufacturerName77.name = "manufacturerName77";
options_manufacturerName77.oncha = "reloadsecondlist";
options_manufacturerName77.href = "/ci/getGlobalManufacturerJquery.action";
options_manufacturerName77.hrefparameter = "mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=3&gameFileName=dcdscd&titleName=Bubble boom chalenge&titleID=11";
options_manufacturerName77.formids = "TitleGameHandsetsForm";
jQuery.struts2_jquery.bind(jQuery('#manufacturerName77'),options_manufacturerName77);
});
</script>
</div>