EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: JeroenvdV on February 22, 2023, 12:22:17 AM



Title: Filebox not part of serialize() method output
Post by: JeroenvdV on February 22, 2023, 12:22:17 AM
Hi,

I am using a filebox in my form. When I use the native javascript serialize() or serializeArray() method to retrieve all Form input field names and values, the filebox input is missing. Is this as intended or am I doing something wrong here?

Code:
        <form id="ff" method="post" > 
            <input class="easyui-textbox" name="first_name" style="width:200px;">
            <input class="easyui-filebox" name="document" style="width:200px;">
        </form>

        <script type="text/javascript">
            var fields = $('#ff').serialize();
            console.log(fields);  // output: first_name=&document=
    
            $(function() {
                var fields = $('#ff').serialize();
                console.log(fields);  // output: first_name=
            });
        </script>



Title: Re: Filebox not part of serialize() method output
Post by: jarry on February 23, 2023, 06:57:01 PM
Data from file select elements is not serialized by 'serialize' method. Please try to use FormData object instead.


Title: Re: Filebox not part of serialize() method output
Post by: JeroenvdV on February 24, 2023, 12:54:02 AM
Thank you Jarry, I can work with that.

Cheers