Upload Plugin

Upload Plugin

jtoler5jtoler5 Posts: 93Questions: 34Answers: 3

How come I cannot specify extra data to be sent with the upload plugin? I have the following, which works just fine with editor and making edits, etc. When I go to upload a file, I get "No Ajax option specified for upload plug-in" in the browsers console window.

 editor = new $.fn.dataTable.Editor({
        ajax: {
            url: ajax_url,
            data: ajax_data
        },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    That looks like it should work. Could you show me your full code?

    Thanks,
    Allan

  • jtoler5jtoler5 Posts: 93Questions: 34Answers: 3

    Sure. Was too long to paste directly in here.

    http://pastie.org/10318658#18

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Thanks - got it now!

    So the issue is that the upload plug-in will only use the ajax parameter if it is a string. If it is not, then it looks for an ajax parameter in the field configuration object (charges.doumentId in this case). That isn't present in your code, and the combination of these two factors is why the error is occurring.

    If you add an ajax option, basically the same as your object used for ajax that should solve the issue.

    Regards,
    Allan

  • jtoler5jtoler5 Posts: 93Questions: 34Answers: 3
    edited July 2015

    I think that makes sense now. Was wondering how the editor class would get the extra post information to perform the query correctly. But I guess because the editor upload performs a separate query before hitting 'save' it will not skip the original Ajax defined and error out when running the save query?

    To be clear I put something like the following under the field for documentId?

    options: {ajax: 'somepage.php'} 
    
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Yes, your description is exactly correct.

    But for the ajax property - it just attaches straight to the field configuration:

                {
                    label: "Document:",
                    name: "charges.documentId",
                    type: "upload",
                    dragDrop: false,
                    clearText: "Delete",
                    "display": function ( val, row ) {
                        return val && row.uploads.webPath ?
                        '<img src="../generateThumbnail.php?pdf='+row.uploads.webPath+'"/>' :
                            'No image';
                    },
                    ajax: ...
                }
    

    Allan

This discussion has been closed.