AnsweredAssumed Answered

Submit a form with enctype='multipart/form-data' using AJAX

Question asked by pylady on Jul 15, 2015
I have a enctype="multipart/form-data" form with a file upload option. I created Java Backed WebScript that allows clients to upload files via POST. I can successfully upload files, it works, but as soon as the file is finished uploading I want to redirect to document-details page of the uploaded document.

In my *.html.ftl I have:

<form method="post" id="${id}-form" enctype="multipart/form-data" action="${action}" enctype="multipart/form-data">
<input type="file" name="fileField">
<span id="${id}-form-submit" class="yui-button yui-submit-button">
     <span class="first-child">
         <button type="button">${msg("button.upload")} </button>

And in .js file:

this.form = new Alfresco.forms.Form( + "-form");
this.form.setAJAXSubmit(true, {
     successCallback: {
         fn: this.onSuccess,
         scope: this
      failureCallback: {
         fn: this.onFailure,
         scope: this

this.widgets.submitButton = Alfresco.util.createYUIButton(this, "form-submit", null,
     type: "submit"

In onSuccess function I tried to use response for redirection, but my problem is that it never enters onSuccess nor onFailure function. No errors in a console. I think that my AJAX call is not good, but I can't figure out what to change. Can anybody give me a suggestion? Thanks in advance!