weixin_33714884 2016-12-16 14:00 采纳率: 0%
浏览 244

android上的jQuery ajax调用

I have some html and javascript code running on a WIFI module that runs a webserver. At a certain point, a jquery ajax call is done like so:

reqData = JSON.stringify({FileName: L_JSON_FILENAME, CmdArr: [["read", "cmduart", "data"]]});
jQuery.ajax('' + _szFileRequest,
        {
            data: reqData,
            dataType: 'json',
            contentType: "application/json",
            async: false,
            type: 'POST',
            success: function (data, textStatus, jqXHR) {
                ReturnedColumn = handleData(data, textStatus, jqXHR);
            },
            error: function (jqXHR, textStatus, errorThrown)
            {
                ReturnedColumn = "error";
            }
        });

Now I want to do the same thing on an android app.

I am currently working in Android Studio.

I have read something about a JSONobject and using toString. But I have also read about using AsyncHttpClient and using RequestParams.

What is the best way to accomplish this call?

  • 写回答

2条回答 默认 最新

  • weixin_33690963 2016-12-16 14:41
    关注

    I use Retrofit : https://square.github.io/retrofit/ It's perfect to make HTTP calls, and it has converters, to ease conversions from JSON, XML, and other format to java

    Some examples : https://guides.codepath.com/android/Consuming-APIs-with-Retrofit

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭