TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Istudent Rana
1.4k
360
85k
How to pass string array to asp.net mvc action method or Api
Feb 18 2018 5:46 PM
I am trying to pass strings array to my mvc action but I am getting Null value.
This is my javascript/Jquery
var array = ["Good Morning", "Good Afternoon", "Good Evening"]
var postData= { imageList: array };
$('button').on('click', function () {
$.ajax({
url: "/Home/Greetings",
type: 'POST',
data: postData,
dataType: "json",
traditional: true,
success: function (data) {
array = [];
},
error: function (xhr, status, err) {
}
});
});
My Code in Asp.net MVC is
[HttpPost]
public string Greetings(List
postData)
{
string result = "";
foreach(var item in postData)
{
result += item + " ";
}
return result;
}
Reply
Answers (
12
)
I ask a question about checkbox in mvc
Post data to web api with entity framework using aspx page