Created
July 19, 2015 16:35
-
-
Save paggiogriot/c9504226a6b157380909 to your computer and use it in GitHub Desktop.
Passing Javascript array to ASP.NET MVC Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can try json.net library to solve your issue | |
[JsonFilter(Param = "attributes", JsonDataType = typeof(AttributeViewModel[]))] | |
public JsonResult Save(AttributeViewModel[] attributes) | |
At client: | |
$.ajax({ | |
type: 'POST', | |
url: url, | |
async: true, | |
data: JSON.stringify(attributes), //!!! Here must be the same name as in controller method | |
dataType: 'json', | |
contentType: 'application/json; charset=utf-8', | |
success: function (data) { | |
}, | |
error: function (xhr, ajaxOptions, thrownError) { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment