我有一個問題,加載XML數據到JavaScript使用jQuery。Javascript XML加載jQuery
我這裏有一個xml:
<config>
<device>
<node>1</node>
<name>Block</name>
<description>Block in saloon</description>
<area>Salon</area>
</device>
<device>
<node>2</node>
<name>Line</name>
<description>Lottr</description>
<area>Living room</area>
</device>
</config>
我想找到設備名稱,其中節點是= 2
這裏是我的代碼:
$.ajax({
type: "GET",
url: "config2.xml",
dataType: "xml",
success: function(xml) {
var kurs = $(xml).find('name').text();
alert(kurs);
}
});
應該是什麼我把var kurs?
我不明白你的問題。你想把什麼放在'kurs'裏面,爲什麼? –
問題到底是什麼?文件是否被加載? – Lix