从 android 手机的phonegap应用程序中的url解析json

发布于 2024-12-07 21:09:13 字数 290 浏览 0 评论 0原文

嗨,朋友们,到目前为止,我只在 Android 本机应用程序中工作。我第一次尝试在 Android 设备的手机间隙中创建应用程序。

我想点击一个url,然后我得到json格式的返回数据。我不知道如何在 javascript 中编写代码来访问 URL 并获取返回数据。请通过提供一段代码或任何教程来帮助我点击网址并获取返回数据。从返回的数据中我需要进行 json 解析,请指导我在 javascript 中进行 json 解析。

请各位朋友帮帮我......

Hi friends so far i have been worked only in android native app. First time i am trying to create an app in Phone gap for android devices.

I want to hit an url and there i get a return data in json format. I dont know to write a code in javascript to hit an URL and get back a return data. Please help me by giving a piece of code or any tutorial to hit an url and get the return data. From that returned data i need to do json parsing, pls guide me in json parsing in javascript too.

Please help me friends......

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

鸢与 2024-12-14 21:09:13

这取决于您尝试使用 GET 还是 POST 发出请求。您只需要使用 JSONRequest

如果您尝试仅使用简单的 GET 请求,那么您的语法将如下所示:

requestNumber = JSONRequest.get(
    "http://yourdomainname.com/request", 
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 

如果您想使用 POST 并且需要发送一些信息,这里是例如:

requestNumber = JSONRequest.post(
    "http://yourdomainname.com/request", 
    {
        username: "user",
        action: "actionname"
    }, 
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 

It depends if you are trying to do a request using GET or POST. You just need to use JSONRequest

If you are trying to just use a simple GET request then your syntax would look something like this:

requestNumber = JSONRequest.get(
    "http://yourdomainname.com/request", 
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 

If you are wanting to use POST and you need to send some information here is an example for that:

requestNumber = JSONRequest.post(
    "http://yourdomainname.com/request", 
    {
        username: "user",
        action: "actionname"
    }, 
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 
很酷不放纵 2024-12-14 21:09:13

在phonegap wiki上有一个关于此的教程:

http:// wiki.phonegap.com/w/page/36868306/UI%20Development%20using%20jQueryMobile

这正是您正在寻找的:)

好运气好!

There is a tutorial of this on the phonegap wiki:

http://wiki.phonegap.com/w/page/36868306/UI%20Development%20using%20jQueryMobile

It just what you are looking for :)

Good Luck!

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