
js问题,jquery问题
<script>functionset_syyj(){$("#select9option").remove();jQuery.ajax({type:'GET',url:'...
<script>
function set_syyj(){
$("#select9 option").remove();
jQuery.ajax({
type: 'GET',
url: 'api/get_zbsy_state.php',
dataType: 'json',
success: function(arr) {
jQuery.each(arr, function(k, v){
$('.red888').html(v.FundName);
$('#syname').val(v.FundName);
$('#syids').val(v.fundid);
$('#cdate').val(v.buy_date);
if(arr.length>0){
var syl=Math.round((v.earn/v.ori_buy_fee)*100);
$("#select9").append("<option value='"+v.fundid+"'>"+v.FundName+",目前收益"+syl+"%"+"买入日期"+v.buy_date+"</option>");
}
;
});
}
});
}
</script>
arr.length>0 没效果
类型为object的,怎么判断呢? 是的echo json_encode($result); 输出来的?这么判断呢? 展开
function set_syyj(){
$("#select9 option").remove();
jQuery.ajax({
type: 'GET',
url: 'api/get_zbsy_state.php',
dataType: 'json',
success: function(arr) {
jQuery.each(arr, function(k, v){
$('.red888').html(v.FundName);
$('#syname').val(v.FundName);
$('#syids').val(v.fundid);
$('#cdate').val(v.buy_date);
if(arr.length>0){
var syl=Math.round((v.earn/v.ori_buy_fee)*100);
$("#select9").append("<option value='"+v.fundid+"'>"+v.FundName+",目前收益"+syl+"%"+"买入日期"+v.buy_date+"</option>");
}
;
});
}
});
}
</script>
arr.length>0 没效果
类型为object的,怎么判断呢? 是的echo json_encode($result); 输出来的?这么判断呢? 展开
1个回答
展开全部
首先得确认返回的数据是不是 数组。
所以你要 alert(typeof(arr))一下。
我怀疑你的数据 是 JSON格式的。
你写一个数据的例子来看一下。
所以你要 alert(typeof(arr))一下。
我怀疑你的数据 是 JSON格式的。
你写一个数据的例子来看一下。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询