0

I'm trying to build an extension for WordPress, in which I want to get form data after submission, the problem is with forms that has input file, I only want to take some information from the database but after the file has been successfully loaded, is there an event that fires after any input file has finished loading?
I tried using submit event but It will only take the before last data in the database, because the file has not been successfully uploaded at the that time. here's my code so far.

jQuery(function ($) {
    $(document).ready(function(){
        var inputValues = [];
        // Here's the event I'm using
        $("form").submit(function( event ) {    
            var inputs = $(this).find("input, textarea, button, select");
            inputs.each(function(index){
                inputValues.push($(this).val());
            });
            }

            var formObj = {
            action      : "users_inputs",
            userValues  : inputValues
            };
            // WORDPRESS AJAX
            jQuery.post(users_obj.ajax_url, formObj);

        event.preventDefault();
        });

    });

Any Ideas ?
Thanks!

Berzerkfar
  • 45
  • 5
  • What do you mean by "after any input file has finished loading"? How are you loading the files? – Barmar May 02 '18 at 21:04
  • You can't submit `` using the code you show, it can't be serialized by jQuery. You need to use `FormData`. – Barmar May 02 '18 at 21:06
  • Are you asking how to upload a file using jQuery AJAX? Then this is a duplicate of https://stackoverflow.com/questions/2320069/jquery-ajax-file-upload – Barmar May 02 '18 at 21:07

0 Answers0