I have a piece of javascript that posts to an action method, and with it some data. This data is in the form:
pageID 1
photos[1] 2
photos[2] 1
My Action Method looks as follows:
public ActionResult PosImage(IEnumerable<int> photos, int pageID)
Naturally, pageID comes through in the form data, but photos is always null.
Is it possible for ASP.MVC to bind like this?
The JS that handles the post looks as follows:
var ids = { 'photos': {}, 'pageID': SitePhotos.site_id };
$('#stone-photo-sortable li').each(function (i) {
i++;
var id = $(this).attr('rel');
ids.photos[id] = i;
});
$.ajax({
type: "POST",
url: '/backend/site/posimage/?timestamp=' + new Date().getTime(),
dataType: 'json',
data: ids,
beforeSend: function () { },
complete: function () { },
success: function (html) {
if (html.worked == 1) {
Notify.add('success', 'New Positions saved to the database..');
} else {
Notify.add('failure', 'Couldn\'t save positions.');
}
}
});