jquery serializeArray() results sometimes in empty string or empty array

JuLiaN_RoX

New Member
I have an \[code\]aspx.net\[/code\] page with a large form to add an order.
This page contains a table with many order lines.
Per order line, there are 20 form fields and 5 hidden fields.There is a print button to print the order, but before that it has to save it first.My problem is that when I use \[code\]$("form").serializeArray()\[/code\], the array is 1 to 1.000.000 times empty.
It doesn't matter which browser I use.This is making me crazy because lot's of users are calling me to fix this problem a.s.a.p.
I don't know to where to start debugging.
  • Is \[code\]serializeArray()\[/code\] the problemen?
  • Or maybe the postdata is to large or corrupt?
  • Maybe the \[code\]WebMethod\[/code\] needs some extra attributes?
Here is my print button\[code\]<input type='button' title='Print' onclick='PrintOrder(true)' />\[/code\]\[code\]function PrintOrder(autosave) { if (autosave) { // save my order and call a callback function after it's completed AutoSaveForm(function () { PrintOrder(false); }); } else { // show my pdf page window.open('printorder.pdf'); return; }}var inAutoSaveForm = false;// this function is needed to autosave my order// fn is a callback function when it's successfull done.function AutoSaveForm(fn) { if (!inAutoSaveForm) { // serializeArray to post my form by the ajax function var fields = $("form").serializeArray(); // json format var myData = http://stackoverflow.com/questions/14490246/{'orderId': orderId, 'fields': fields }; myData = http://stackoverflow.com/questions/14490246/JSON.stringify(myData); ShowLoader(); $.ajax({ type:"POST", url: "/Order.aspx/AutoSave", contentType: "application/json; charset=utf-8", timeout: (1000 * 60 * 10), data: myData, dataType: "json", success: function () { setTimeout(function () { fn.call(); }, 25); }, error: function (x, t, m) { alert("Error, please try again later.\n\n" + t); }, complete: function (msg) { // .. do nothing yet } }); inAutoSaveForm = true; } else { fn.call(); }}\[/code\]Here is my .NET code to save the order.
Maybe I have to put some attributes to the WebMethod ?\[code\][WebMethod]public static string VerwerkForm(field[] fields) { // do the magic return "ok";}public class field { public string name { get; set; } public string value { get; set; }}\[/code\]
 
Back
Top