0

I'm having problems getting my jquery post of a list of integers to post back to the action method in the controller.

My post jquery is the folling:

    $.post('/Section/RunAlgorithm', {
        test: JSON.stringify([1, 2])
    }, function (response) {
    }, 'json');

My controller action is defined as follows:

public ActionResult RunAlgorithm(int[] test)

When posting to the method my test parameter is null. How can I resolve this and where does the problem exist in my code?

Thank you

masterwok
  • 4,868
  • 4
  • 34
  • 41

1 Answers1

1

I'm so tired o___O .. Here's the solution:

    $.ajax('/Section/RunAlgorithm', {
        type: 'POST',
        traditional: true,
        data: {
            test: [1, 2, 3]
        }
    });
masterwok
  • 4,868
  • 4
  • 34
  • 41