ajax傳輸局,後臺接收不到
1、\'counties':String($('#counties').val()),
2、toString()
原因描述: alert(
citiesData )是有值的,在 action裡面 接收到的就是null,原因是我用了
<link rel="stylesheet"
href="<%=path%>/multiple-select/bootstrap/css/bootstrap.css" />
<link rel="stylesheet"
href="<%=path%>/multiple-select/multiple-select.css" />
<script src="<%=path%>/multiple-select/multiple-select.js"></script>
multiple-select.css,資料值型別 不太匹配,需要轉成string。
程式碼:
var citiesData = $("#cities").val().toString();
alert("1:"+citiesData);
if(citiesData!= undefined &&citiesData!=""){
$.ajax({
type: 'POST',
datatype:'json',
data: {"citiesData":citiesData
},
url: '<%=path%>/rpms/OurPartnerListAction/getPartnerCounties.do',
success:function(data){
var num=0;
$(data).each(function(i,obj){
num++;
$('#counties').append("<option value='"+obj.countyCode+"'>"+obj.areaName+"</option>");
});
if(num<=1){
$('#counties').attr("disabled","disabled");
}
$('##counties').change(function(){
alert("改變了鄉");
// console.log($(this).val());
}).multipleSelect({
width:'100px'
});
},
error: function(result){
keyan.ajaxRespMsg(result);
}
});
解決方法:
1、counties':String($('#counties').val()),
2、
counties':$('#counties').val(),toString()