-1

Hello people I'm doing a web application some orthodox, my method is AJAX using java and javascript.

And I asking me if is possible set a array from javascript to Servlet.

Juan BG
  • 87
  • 1
  • 2
  • 7
  • Possible duplicate http://stackoverflow.com/questions/14099508/passing-javascript-array-to-servlet – brk Jan 27 '16 at 09:26

1 Answers1

-1

Yes it is possible!

var test = [];
$.ajax({
    type: 'get', 
    url: 'someurl',
    dataType: 'JSON',
    data: { 
      test: JSON.stringify(test) 
    },
    success: function(data) {

    },
    error: function(data) {
        alert('fail');
    }
});

And in servlet:

String json = request.getParameter("test");
P. Jairaj
  • 1,033
  • 1
  • 6
  • 8