0

The following is the ajax code used by the website to change the two feilds ability_bpm and endurance_bpm

function editBatch_Ajax(id, batch_data){
    $.ajax({
      url: '/batches/'+ id,
      type: 'put',
      context: 'this',
      dataType: 'json',
      data: {
        batch: batch_data,
        id: id
      },
      success: function(msg){ 
        $('#' + id + ' .' + Object.keys(batch_data)[0]).text(batch_data[Object.keys(batch_data)[0]]);
      },
      error: function(jqXHR, textStatus, errorThrown) {}
    });
}

sends a PUT request from a Ajax call. Now I want to do the same thing from an android application. here

    data: {
 batch: batch_data,
 id: id
 },

will be something like

data : { 
     batch: {
     ability_bpm: 40
     },
     id: 0
    }

The website that I webserver is running at http://www.rudimentor.me/

I am a beginer to android. So far I have gotten to display the data available at the server in a listview I need to have this to change the values on the server. I have also tried to send request from a rest client in a browser but cannot figure it out

Tristan
  • 3,530
  • 3
  • 30
  • 39
timberlake
  • 777
  • 6
  • 13

2 Answers2

0

You can use this library to make your HTTP Calls:

http://loopj.com/android-async-http/

Here you can find some example how to use this library:

https://github.com/franzejr/android-boilerplate/blob/master/app/src/main/java/controllers/SampleController.java

And also you can use the GSON to help you handling JSONs. It's pretty straightforward.

Franzé Jr.
  • 1,194
  • 13
  • 20
0

I would say there are a number of options. I prefer Retrofit.

Here is a link to a question with some good comparisons of the various options.

Comparison of Android networking libraries: OkHTTP, Retrofit, and Volley

Community
  • 1
  • 1
nPn
  • 16,254
  • 9
  • 35
  • 58