EasyUI Forum
April 29, 2024, 04:32:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Filebox not part of serialize() method output  (Read 931 times)
JeroenvdV
Newbie
*
Posts: 21


View Profile Email
« 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>

Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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.
Logged
JeroenvdV
Newbie
*
Posts: 21


View Profile Email
« Reply #2 on: February 24, 2023, 12:54:02 AM »

Thank you Jarry, I can work with that.

Cheers
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!