0

I have to make a json call to home controller where I need to pass multiple arrays.

 var assetids = new Array(N);
 var faultTimes = new Array(N);
 var messages = new Array(N);
 var curtailments = new Array(N);

 //populate above arrays with values then make a JSON call

$.getJSON('Home/AcknowledgeMany', {
                        assetid: assetids,
                        loggedBy: $("#UserName").text(),
                        faultTime: faultTimes,
                        message: messages,
                        curtailment: curtailments
                    }, function (result) {
                          alert(result); 
                       }

The homecontroller has following action result

public string AcknowledgeMany(int[] assetId, string loggedBy, string[] faultTime, string[] message, string[] curtailment)
 {

 return("Acknowledged");
}

I receive null values for all the arrays when I make this call. Can someone help me passing arrays.

0

1 Answer 1

0

Try setting the traditional flag

For detail help see this question

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

3 Comments

This works great. Thanks. I wonder if I could achieve the same without using $.ajax. Does $.getJSON provide an option of traditional:true ?
I don't think so, As jquery site doesn't have it in its description api.jquery.com/jQuery.getJSON
If your problem is solved you can acknowledge by accepting that answer, So your question also helps other solving there problem :)

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.