jQuery.serializeArray() works also outside a form

 

Quote from jQuery docs: "Note that serializeArray() only works on form elements, using this method on another element will not work."

(http://docs.jquery.com/Ajax/serializeArray)

 

However, this is wrong, at least in 1.4.2 because I’m using the function to send some params to a controller this way:

<input type="hidden" id="LicenseId" name="LicenseId" value="" class="markerDTO" />
<input type="hidden" id="marker_Color" name="marker.Color" value="" class="markerDTO" />
<input type="hidden" id="marker_Id" name="marker.Id" value="" class="markerDTO" />

The 3 fields are not included in any <form></form>

var oo = $(‘.markerDTO‘).serializeArray();

jQuery.ajax({
            url: ‘-my-url-‘,
            dataType: ‘json’,
            data: jQuery.param(oo),
            complete: function()
            {
                var licenseId = $("#LicenseId").val();
                var color = $("#marker_Color").val();

                $(‘div.marker-color[license-id=’ + licenseId + ‘]’).css(‘background-color’, color );

                // unblock when remote call returns
                jQuery.unblockUI();
            }
        });

 

Also it works with just one input:

var oo = $(‘#LicenseId’).serializeArray();