ASP MVC 3 submit url parameters using AJAX and JQUERY

kyleshamrock

New Member
I've got a problem using ASP.NET MVC3, AJAX and JQUERY. I've got the following function\[code\][HttpPost]public bool Update(int id, FormCollection collection)\[/code\]This is my jQuery Source:\[code\]$(document).ready(function () { $('#btnUpdate').click(function (e) { // Cancel default action e.preventDefault(); var formCollection = $('#formId').serialize(); $.ajax({ cache: false, type: 'POST', url: '@Url.Action("Action","Controller")', data: { id: $('#id').val(), collection: formCollection }, success: function (data) { alert(data); }, error: function (xhr, ajaxOptions, thrownError) { alert('Error during process: \n' + xhr.responseText); } }); });});\[/code\]The id parameter submitted successfully, but the collection (FormCollection) includes an array with {[0]: 10000, [1]: collection}. I can't fix the problem. When I redesign the solution like this:\[code\][HttpPost]public bool Update(FormCollection collection)$(document).ready(function () { $('#btnUpdate').click(function (e) { // Cancel default action e.preventDefault(); $.ajax({ cache: false, type: 'POST', url: '@Url.Action("Action", "Controller")', data: $('#formId').serialize(), success: function (data) { alert(data); }, error: function (xhr, ajaxOptions, thrownError) { alert('Error during process: \n' + xhr.responseText); } }); });});\[/code\]everything works fine. What I'm doing wrong in passing 2 parameter?THX!!!
 
Back
Top