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.

Sirko
  • 72,589
  • 19
  • 149
  • 183
lostpacket
  • 1,383
  • 8
  • 26
  • 38

1 Answers1

0

Try setting the traditional flag

For detail help see this question

Community
  • 1
  • 1
Fraz Sundal
  • 10,288
  • 22
  • 81
  • 132
  • This works great. Thanks. I wonder if I could achieve the same without using $.ajax. Does $.getJSON provide an option of traditional:true ? – lostpacket Jul 02 '12 at 13:46
  • I don't think so, As jquery site doesn't have it in its description http://api.jquery.com/jQuery.getJSON/ – Fraz Sundal Jul 02 '12 at 13:53
  • If your problem is solved you can acknowledge by accepting that answer, So your question also helps other solving there problem :) – Fraz Sundal Jul 02 '12 at 13:54