Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery serializeArray() results sometimes in empty string or empty array
    primarykey
    data
    text
    <p>I have an <code>aspx.net</code> page with a large form to add an order.<br> This page contains a table with many order lines.<br> Per order line, there are 20 form fields and 5 hidden fields.</p> <p>There is a print button to print the order, but before that it has to save it first.</p> <p>My problem is that when I use <code>$("form").serializeArray()</code>, the array is 1 to 1.000.000 times empty.<br> It doesn't matter which browser I use.</p> <p>This is making me crazy because lot's of users are calling me to fix this problem a.s.a.p.<br> I don't know to where to start debugging.</p> <ul> <li>Is <code>serializeArray()</code> the problemen?</li> <li>Or maybe the postdata is to large or corrupt?</li> <li>Maybe the <code>WebMethod</code> needs some extra attributes?</li> </ul> <p>Here is my print button</p> <pre><code>&lt;input type='button' title='Print' onclick='PrintOrder(true)' /&gt; </code></pre> <pre><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 = { 'orderId': orderId, 'fields': fields }; myData = 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></pre> <p>Here is my .NET code to save the order.<br> Maybe I have to put some attributes to the WebMethod ?</p> <pre><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></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload