user2668436
user2668436

Reputation: 5

jquery file upload submit callback

im using the blueimp jquery file upload plugin . this code

<script>
    $('#fileupload').bind('fileuploadsubmit',function(e,data){
        var inputs = data.context.find(':input');
        if (inputs.filter('[required][value=""]').first().focus().length){
            return false;
        }
        data.formData = inputs.serializeArray();
    });
                </script>    

is supposed to send all files along with the form data to the server. For some reason its not working . Firebug says ReferenceError: $ is not defined when this page is loaded. Should i define this callback in the main js ? ( I am able to add additional form data for the selected files when uploading and save the names onto the database. When using titles for each uploaded file these values are sent saved as typed when uploaded one by one. When uploaded all at once the value is the same as the first input. This callback supposedly uploads thses data one by one.

Upvotes: 0

Views: 2951

Answers (2)

benestar
benestar

Reputation: 562

As shown in your jsfiddle, all the script includes are placed at the bottom of the page. So you either move them before your script tags, or you move your script tags to the bottom of the page. Otherwise jQuery will not be defined when you want to use it.

Upvotes: 1

poodle
poodle

Reputation: 107

Fix this :

(e, data>  

to

 (e, data)

Upvotes: 0

Related Questions