Javascript / jQuery – Parse将“数据”作为HTML返回以供进一步选择?

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();
    });
}

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...