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

    评论

报告相同问题?