ajax-返回json
发布时间:2020-12-15 21:04:32 所属栏目:百科 来源:网络整理
导读:function qSubType(selobj){ if(selobj!=null){ var caseSubType=document.getElementById("caseSubType"); caseSubType.options.length=0;//清空select下拉框 if(selobj.value.length!=0){ jQuery.ajax({ type:"POST",url:"${ctx}/partner/product.do?method
function qSubType(selobj){ if(selobj!=null){ var caseSubType=document.getElementById("caseSubType"); caseSubType.options.length=0;//清空select下拉框 if(selobj.value.length!=0){ jQuery.ajax({ type:"POST",url:"${ctx}/partner/product.do?method=qProductSubType",//处理请求的action方法 //data:"selectId="+jQuery("#"+selectId).val(),//传递的参数 data:{'name':selobj.options[selobj.selectedIndex].text,'id':selobj.options[selobj.selectedIndex].value},//传递的参数 dataType:"html",success:function(data) { if(data!=null&&data!=''){ data=eval('('+data+')'); if(data.subtype!=null&&data.subtype!=''){ var subtypearray=data.subtype; if(subtypearray!=null&&subtypearray.length!=0){ for(var i=0;i<subtypearray.length;i++){ var temp=subtypearray[i]; var value=temp.remark; var text=temp.name; caseSubType.options.add(new Option(text,value)); } } } } },error : function() { //alert("审核失败!"); } }); } } } --返回json {subtype:[{"deleted":0,"flag":0,"id":1027,"mark":"云主机产品","name":"云主机虚拟机","parent_id":1026,"remark":"1"},{"deleted":0,"id":1028,"name":"云主机物理机","remark":"2"},"id":1029,"name":"定制云虚拟机","remark":"3"},"id":1030,"name":"定制云物理机","remark":"4"}]} --java String json="{subtype:""}"; JSONArray jo = JSONArray.fromObject(productSubTypeList); json="{subtype:"+jo.toString()+"}"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |