如何在 Palm Pre 上的 webOS 应用程序中访问本地 XML 文件中的数据?

发布于 2024-08-05 00:17:52 字数 829 浏览 2 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流星番茄 2024-08-12 00:17:52

你检查过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.

对岸观火 2024-08-12 00:17:52

您需要让控制器知道发生了变化:

this.controller.modelChanged(xxx);

祝您好运

You need to let the controller know there was a change:

this.controller.modelChanged(xxx);

Good luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文