响应 XML
<Response>
<ClientDetail>
<FirstName>a</<FirstName>
<LastName>a</LastName>
<Status>Off</Status>
<City>a</City>
<ZipCode>12346</ZipCode>
............
</ClientDetail>
<ClientDetail>
<FirstName>b</<FirstName>
<LastName>b</LastName>
<Status>Off</Status>
<City>b</City>
<ZipCode>321546</ZipCode>
........
</ClientDetail>
</Response>
解析响应
$($.parseXML(response)).find("ClientDetail").each(function(){
var respRow='<tr>'+
'<td class="ClientName">'+$(this).find('LastName').text()+', '+ $(this).find('FirstName').text()+
'</td><td class="ClientStatus">'+$(this).find('Status').text()+
'</td><td class="DateOfBirth">'+$(this).find('BirthDate').text()+
'</td><td class="searchData" style="display:none;">'+this+'</td>';
$('#clientSearchResult > tbody:last').append(respRow);
});
将 XML 设置为隐藏<td>
<td class="searchData" style="display:none;">'+this+'</td>'
回读
var searchData = $(row).find('.searchData').data();
alert($(searchData ).find('Status').text());
如果这不是正确的做法,那我该怎么做?