0
我知道我的问题可能会问以前几次。我尝试了很多解决方案,但它对我没有用。使用JQuery和PhoneGap解析XML
我想构建一个使用JQuery和PhoneGap从XML文件中获取数据的移动应用程序。
这是我的XML文件:
<book>
<chapter id="1">
<title>title 1</title>
<question id="1.1"> Question 1 </question>
<answer id="1.1.1"> answer for q1 </answer>
</chapter>
<chapter id="2">
<title>title 2</title>
<question id="2.1"> Question 2 </question>
<answer id="1.2.1"> answer for q2 </answer>
</chapter>
</book>
,这是我的JavaScript:
$(document).bind("pageshow", function() {
$.ajax({
type: 'GET',
url:'Book.xml',
datatype:'xml',
success:function(xml){
alert("success");
}
});
});
如果我从来没有表现出成功的警报功能,但是如果在此代码显示的警报 的$(document).bind( “pageshow”,函数(){
$.ajax({
type: 'GET',
url:'Book.xml',
datatype:'xml',
success: alert("success");
});
});
我坚持在这里,我CA不添加任何进一步的代码。
这就是我在控制台中得到的结果 XMLHttpRequest无法加载file:///Book.xml。 Access-Control-Allow-Origin不允许Origin null。 – user1748687 2013-03-26 15:02:38