Quantcast
Channel: Alfresco Forums - Alfresco Share
Viewing all articles
Browse latest Browse all 877

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

$
0
0

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></span> 

And in .js file:

this.form=new Alfresco.forms.Form(this.id+"-form");this.form.setSubmitElements(this.widgets.submitButton);this.form.setAJAXSubmit(true,{ 
     successCallback:{ 
         fn:this.onSuccess, 
         scope:this}, 
      failureCallback:{ 
         fn:this.onFailure, 
         scope:this}});this.form.setSubmitAsJSON(false);this.form.setAjaxSubmitMethod("POST");this.form.init(); 
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!

4.2.c

Viewing all articles
Browse latest Browse all 877

Trending Articles