1
我很難讓JQueryMobile過濾器函數在我正在使用的腳本上工作。JQueryMobile過濾XMLhttprequest
我創建了一個簡單的xmlhttp請求,用於從175個條目和4列的XML文件中收集數據。輸出是好的。現在我不想過濾這張桌子。但是,當它連接起來沒有效果。
任何幫助表示讚賞
<script type="text/javascript">
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","Issue.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write('<table border="1" cellspacing="1" cellpadding="5">')
var Asset = xmlDoc.getElementsByTagName("Attribute");
for (x = 0; x <= Asset.length; x++) //Asset.length
{
document.write("<tr>");
document.write("<td>" + xmlDoc.getElementsByName("Number")[x].childNodes[0].nodeValue) + "</td>";
document.write("<td>" + xmlDoc.getElementsByName("Name")[x].childNodes[0].nodeValue) + "</td>";
document.write("<td>" + xmlDoc.getElementsByName("Address")[x].childNodes[0].nodeValue) + "</td>";
document.write("<td>" + xmlDoc.getElementsByName("Phone")[x].childNodes[0].nodeValue) + "</td>";
document.write("</tr>");
}
document.write("</table>");
</script>
的XML:
<?xml version="1.0" encoding="UTF-8"?>
<Assets pageSize="2222222" pageStart="0" total="175">
<Asset href="www.home1.com">
<Attribute name="Number">123123123</Attribute>
<Attribute name="Name">asdqweqweqwe</Attribute>
<Attribute name="Address">dsffdfsdfdasfsda</Attribute>
<Attribute name="Phone">123123123</Attribute>
</Asset>
<Asset href="www.home2.com">
<Attribute name="Number">4344433</Attribute>
<Attribute name="Name">ssssss</Attribute>
<Attribute name="Address">ddddd</Attribute>
<Attribute name="Phone">6666666</Attribute>
</Asset>
</Asset>
工作表頭:
document.write('<table data-role="table" data-filter="true" data-input="#filterTable-input" id="thetable" class="ui-responsive table-stroke">');
document.write('<thead><tr><th>Number</th><th>Name</th><th>Custom</th><th>Owner</th></tr></thead>');
document.write('<tbody>');
好,但不會讓我使用XML文件,對嗎? – SFmtl
這是我的xml的樣子。 – SFmtl
是的,你可以使用XML,我只是保持簡單的例子,所以你會看到過濾器的工作。在你的情況下,只需在你的原始代碼中迭代XML即可在ajax調用的成功部分上構建表。 – ezanker