我必須從服務器讀取XML請求。 如果我在本地保存XML,一切工作正常。來自Webservice的XML語法錯誤jquery
腳本:
$(document).ready(function() {
$.ajax({
type: 'GET',
url: 'http://localhost:1410/?SNO=56789&ASQL=plu%20mec%2010;',
crossDomain: true,
dataType: "jsonp",
success: parseXml
});
});
function parseXml(xml) {
$(xml).find('dataset').each(function() {
$("#output").append($(this).find('var[key="article.name"]').text() + "<br />");
});
}
XML輸出:
<document name="screen">
<section name="status">
<dataset>
<var key="organization.number">2919</var>
<var key="organization.name">Testname</var>
<var key="organization.businessdate">09.02.2013</var>
<var key="situation.number">0</var>
<var key="situation.name">Normalbetrieb</var>
<var key="site.number">0</var>
<var key="site.name">Normalbetrieb</var>
<var key="pricelevel.number">1</var>
<var key="pricelevel.name">Standardpreis</var>
<var key="terminal.number">0</var>
<var key="terminal.name">WebKasse</var>
<var key="terminal.status">open</var>
<var key="terminal.tapster">inactive</var>
<var key="waiter.number">1</var>
<var key="waiter.name">Kellner 1</var>
<var key="table.number">5</var>
<var key="table.balance">3.2</var>
<var key="table.sales">3.2</var>
<var key="profile.number">1</var>
<var key="profile.name">Standard</var>
<var key="execution.severity">I</var>
<var key="execution.code">23600003</var>
<var key="execution.message">Mec article list.</var>
</dataset>
</section>
<section name="plu.list">
<dataset>
<var key="type">article</var>
<var key="article.number">1</var>
<var key="article.name">0,1 l Becher Sekt</var>
<var key="article.displayname"/>
<var key="article.price">3.7</var>
<var key="article.plunumber">1</var>
<action key="STANDARD">book plu 1;</action>
</dataset>
[...]
有了這個代碼我的網頁是空白的,並顯示此錯誤:
SyntaxError: syntax error
<document name="screen"><section name="status"><dataset><var[...]
奇怪的是:我可以在錯誤中看到XML輸出!
如果我改變data type:
到xml
沒有錯誤,頁面空白。
http://img191.imageshack.us/img191/9229/synerr.png解析爲XML如果我在錯誤點擊,我可以看到洞xml文件?! – TheCyX 2013-02-10 11:39:00