webservice将一些数据返回给我.数据实际上只是原始HTML(因此没有XML标头或其周围的标签,只是一段html).
<div class="Workorders">
<div id="woo_9142" class="Workorder">
<span class="Workorder">S1005</span>
<span class="Pn">30-2</span>
<span class="Description">Cooling Fan</span>
<span class="Shortages">3616-1 (SV)</span>
<span class="Company">xxx</span>
</div>
<div id="woo_9143" class="Workorder">
<span class="Workorder">S1006</span>
<span class="Pn">30-2</span>
<span class="Description">Cooling Fan</span>
<span class="Shortages">3616-1 (SV)</span>
<span class="Company">xxx</span>
</div>
</div>
如果是这样的XML:
<workorders>
<workorder id="woo_9142">
<partnumber>30-2</partnumber>
</workorder>
</workorders>
我可以在jQuery中这样做:
$('/workorders/workorder', data).each(function() {
//This would give every partnumber $('partnumber', this).text();
});
如何解析返回的HTML(如开头所述)?
myNamespace.onSuccess = function(request) {
//request contains the raw html string returned from the server
//How can I make this possible:
$(request).find('div.Workorders div.Workorder').each(function() {
//Do something with the Workorder DIV in 'this'
});
}
解决方法:
就像是
myNamespace.onSuccess = function(request) {
$(request.responseText).filter('div.Workorder').each(function() {
$('span.Pn', $(this)).text();
});
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。