Hooking transloadit jquery plugin to my server response

Archived from the Transloadit support forum. Originally posted on September 4, 2013; details may be outdated, see our docs for current behavior. Original thread

Hi

Thank you very much for developing a wonderful platform Transloadit. In my scenario, I am giving all the major task to Transloadit, i.e. uploading the image, resizing it and then uploading it to my S3 bucket.

After this template works, Transloadit comes back to my url with all the information that I had specified in my form action. This is good. Everything is working fine till here.

Now I want to return some information from my server to client. I am not finding a way to hookup this response back to Transloadit plugin, so that I can inform user about couple of things. My scenario is Ajax based, so navigating to url that I specified in form action is not an option.

Please guide. Am I missing something very trivial? Following is my script:

<script type="text/javascript">
$(document).ready(function () {
$('#uploadForm').transloadit({
wait: true,
params: {
auth: { key: "####" },
template_id: "####"
},
onProgress: function (bytesReceived, bytesExpected) {
// render your own progress bar!
$('#progress')
.text((bytesReceived / bytesExpected * 100).toFixed(2) + '%');
},
onError: function (assembly) {
alert(assembly.error + ': ' + assembly.message);
},
onSuccess: function () { alert("Upload done"); },
onResult: function () { alert("On Result");}
});
});
</script>

Regards
Pradeep

Hey Pradeep,

thank you for the kind words, we are happy to help. :slight_smile:

Can you please also add your ajax call and explain how do you intend to “hook” the response into the transloadit jquery plugin?

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Script that I posted is all I coded for Ajax. Other than this I loaded Transloadit plugin. These things are done as per the instructions given on https://transloadit.com/docs#jquery-plugin. I am using ASP.Net MVC here.

Following is the code for my form:

<form id="uploadForm" action="@Url.Action("Upload", "File")" enctype="multipart/form-data" method="POST">
<input id="fileupload" type="file" name="uploadedFiles" multiple="">
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<input type="submit" value="upload" />
</form>

Following is my server side code:

public JsonResult Upload(string transloadit)

{
return Json(true);
}

I am getting a call in this method and I can see Transloadit response in my variable. After this I want to return some information back to client. Like here I am just signalling “true”.

Where do I plug this information? I am not sure how to hook it in Transloadit plugin. I am not triggering any Ajax call. On the click of Submit button, Transloadit starts doing its job. Kindly help.

Hm, unfortunately I still do not fully understand what you are trying to do and where the problem is. : /

Can you please add me on Skype? I think directly chatting will be easier than going back and forth in this ticket. My Skype username is “transloadit_tim”.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos