0

new to ajax and not quite sure whats wrong. I have:

var myArray = [2324.031536  ,
               2355.015241  ,
               2397.099387  ,
               2444.286019];

$(document).ready(function() {                        
        $('#submit').click(function(event) {
            $.get('VsPredictionServlet',{myArray:myArray},function(responseText) { 
                $('#text').text(responseText);
            });
        });
    });

and in servlet:

String[] myArray = request.getParameterValues("myArray");

but myArray is null in servlet.
Any suggestions?

1 Answer 1

1

just do this:

$.get('VsPredictionServlet',{ "myArray": myArray},function(responseText) {

            $('#text').text(responseText);

});

you need to pass parameter as a string.

Sign up to request clarification or add additional context in comments.

1 Comment

use JSON.stringify data = JSON.stringify({ "myArray" = myArray }); $.get('VsPredictionServlet', data ,function(responseText) { $('#text').text(responseText); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.