Search code examples
jqueryajaxtwitter-bootstrapjquery-file-upload

How to get response data in bootstrap-fileinput?


I use bootstrap fileinput to upload files to my server with ajax. The server gives back a json text as result. But I don't know, how to access it.

HTML:

<input 
    id="file-uploader" 
    name="files[]" 
    data-show-caption="false" 
    data-upload-url="dataProcessor.php?s=700" 
    class="file"
    type="file" 
    multiple 
    data-language="de" 
    data-min-file-count="1"
>

JS:

$('#file-uploader').fileinput({
    uploadClass: "btn btn-info",
    removeClass: "btn btn-danger"
});

$('#file-uploader').on('fileuploaded', function(event) {
    // event.data is undefined
});

Solution

  • The event returns 2 parameters. console.log both of them to see what's included

    Like this:

    $('#file-uploader').on('fileuploaded', function(event, data) {
        // and check what's in both params
        console.log(event);
        console.log(data);
    });