我将结果数据集作为地图对象。我使用下面的脚本将数据附加到Html。但它没有影响。
$("#district").change(
function() {
$('#mandal').html('');
var district = {
"district" : $("#district").val()
};
$.ajax({
url : "Reports",
data : JSON.stringify(district),
dataType : 'json',
contentType : 'application/json',
type : 'POST',
async : true,
success : function(res) {
console.log(res.resList.length);
for ( var i = 0; i < res.resList.length; i++) {
console.log("Kalishavali " + res.resList[i]);
$('#mandal').append(
'<option value=' + res.resList[i] + '>'
+ res.resList[i]
+ '</option>');
}
}
});
});
结果数据格式:
{08=Prakasam, 09=S.P.S Nellore, 04=East Godavari, 05=West Godavari, 06=Krishna, 07=Guntur, 13=Kurnool, 01=Srikakulam, 11=Kadapa, 02=Vizianagaram, 12=Anantapur, 03=Visakhapatnam, 10=Chittoor}
这是我的Jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@include file="includes/Header_1.html" %>
<script>
$(function() {
$("#district").change(
function() {
$('#mandal').html('');
var district = {
"district" : $("#district").val()
};
$.ajax({
url : "Reports",
data : JSON.stringify(district),
dataType : 'json',
contentType : 'application/json',
type : 'POST',
async : true,
success : function(res) {
console.log(res.resList.length);
for ( var i = 0; i < res.resList.length; i++) {
console.log("Kalishavali " + res.resList[i]);
$('#mandal').append(
'<option value=' + res.resList[i] + '>'
+ res.resList[i]
+ '</option>');
}
}
});
});
});
</script>
<s:select label="District" list="resList" listKey="key" value="value" name="district" headerKey="-1" headerValue="Select District"/>
Mandal :
<select id="mandal"></select>
答案 0 :(得分:0)
响应无效JSON:
=
而不是:
应该是:
{"08" : "Prakasam", "09" : "S.P.S Nellore" etc...}