用于在同一Table显示两级内容
点击一次,会用ajax从服务器加载json数据,并添加到该行下面
再点击一次,会利用name属性,删除对应的行
function ExpendPatient(srow,pid){ var imgc = "#p"+pid+"imgc"; var imgo = "#p"+pid+"imgo"; if($(imgo).is(":visible")) { $(imgo).hide(); $(imgc).show(); delrows = document.getElementsByName("p"+pid+"study"); for (var i=0;i<delrows.length;i++) { delrows[i].parentNode.removeChild(delrows[i]); } return; } $(imgc).hide(); $(imgo).show(); aurl="xxxxxxxxxxxx?patPk="+pid; try { $.ajax({ url: aurl, dataType: 'json', error: function(XMLHttpRequest, textStatus, errorThrown){ alert('错误原因 ' + textStatus); alert('错误堆栈 ' + errorThrown); alert('返回字符 ' + XMLHttpRequest.responseText); }, success: function(data) { $.each(data,function(i,record){ r = '<tr height="30" name="p'+pid+'study" onclick="DoSomeThing(this,'+record["pk"]+');"]'; r += '<td></td>'; r += '<td>'+record["a"]+'</td>'; r += '<td>'+record["b"]+'</td>'; r += '<td>'+record["c"]+'</td>'; r += '<td>'+record["d"]+'</td>'; r += '<td>'+record["e"]+'</td>'; r += '<td>'+record["f"]+'</td>'; r += "</tr>"; $(srow).after(r); }); } }); } catch(e) { alert(e); } }