0
$.ajax(
{
    type: "POST",
    data: "koala",
    url: "http://localhost:555",
    cache: false,
    success: function(result)
    {       
    },
    failure: function()
    {
    }
});

what will the syntax be to get the value i just sent though with ajax in my java? how will i get the value "koala". assuming you have accpeted the clientSocket connection

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
jambuls
  • 111
  • 11

2 Answers2

0

data accepts a dictionary. i think you have to write something like

data: {"koala": "koala"},

then your server can get and manipulate the data with the variable name "koala". what the server send back is stored in parameter result.

b10n1k
  • 567
  • 5
  • 21
0

Using JAX-RS and Jersey your backend would be something like this

@Path("/")
public class MyResource {


    @POST
    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Animal createAnimal(final String animalName) {
        return dao.create(animalName);
    }
}

Sring MVC is quite similar as well.

Fand
  • 88
  • 1
  • 7