Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created and filled various arrays using jquery. First time, trying to send JavaScript arrays to MVC controller.

Can I have an example how to do that? How can I send the arrays and other variables as well? On the controller side, how can I retrieve the data?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
134 views
Welcome To Ask or Share your Answers For Others

1 Answer

You'll probably want to use jQuery.ajax, with a dataType parameter of 'json'. You can send any JSON object. Possible example:

var obj = {'foo': 'bar'};

$.ajax({
   type: "POST",
   url: "some.aspx",
   dataType: "json",
   contentType: "application/json; charset=utf-8", 
   data: obj,
   success: function(resp){
     alert("Response: " + resp);
   }
 });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...