如何在 Palm Pre 上的 webOS 应用程序中访问本地 XML 文件中的数据?
我是 Mojo 框架和 Palm webOS 的新手。我只想使用 xmlhttprequest (Ajax) 从 XML 文件中检索数据。我正在尝试从以下脚本获取数据。
this.items = [];
var that = this;
var request = new Ajax.Request("first/movies.xml", {
method: 'get',
evalJSON: 'false',
onSuccess:function(transport){
var movieTags = transport.responseXML.getElementsByTagName('movie');
for( var i = 0; i < movieTags.length; i++ ){
var title = movieTags[i].getAttribute('title');
that.items.push({text: title});
}
},
onFailure: function(){ alert('Something went wrong...') }
});
我的 XML 文件位于 first/movies.xml 文件夹中。从那里我试图访问和检索数据。但在 Palm Pre 模拟器的屏幕上不显示任何内容。
那么任何人都可以了解这个问题吗?请提供一个链接,在哪里可以找到从 webOS 中的 XML 文件获取数据的源代码。
I am new at Mojo framework and Palm webOS. I want to just retrieve data from XML files using xmlhttprequest (Ajax). I am trying to get data from following script.
this.items = [];
var that = this;
var request = new Ajax.Request("first/movies.xml", {
method: 'get',
evalJSON: 'false',
onSuccess:function(transport){
var movieTags = transport.responseXML.getElementsByTagName('movie');
for( var i = 0; i < movieTags.length; i++ ){
var title = movieTags[i].getAttribute('title');
that.items.push({text: title});
}
},
onFailure: function(){ alert('Something went wrong...') }
});
My XML files are in the first/movies.xml folder. From that I am trying to access and retrieve data. but not display anything in the screen of Palm Pre emulator.
So can anyone is having idea about this issue? Please give a link where can I find the source code for getting data from XML files in webOS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你检查过xml的路径吗?我的意思是它应该是“/first/movies.xml”而不是“first/movies.xml”。此外,如果路径正确,那么您实际上不会在 Transport.responseXML 中获得任何数据。首先尝试检查它是否正在获取其中的任何数据。如果 url 有任何问题,您将无法在 Transport.responseXML 中获取任何数据。
希望这有帮助。
Have you checked the path of the xml. I mean it should be "/first/movies.xml" instead of "first/movies.xml". and moreover if path is correct than do you really get any data in transport.responseXML. First try to check if it is getting any data in that. If there is any problem with url, you will not get any data in transport.responseXML.
Hope this helps.
您需要让控制器知道发生了变化:
祝您好运
You need to let the controller know there was a change:
Good luck