Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere Is A Success Callback For Jquery Plugin .Net
    primarykey
    data
    text
    <p>I am attempting to use an upload jquery control. The code below successfully connects to my ASP.Net Handler and process's files fine. After processing I need to send back a string of data to the client. </p> <p><a href="https://github.com/BoSchatzberg/jfu-CSharp-Example/tree/master/jfuExample" rel="nofollow">Here is the example</a> I am working off..</p> <p>I am having issues with a few things.. </p> <p>1) How to I send data back to the client from a Handler</p> <p>2) Is anyone familiar to understand where to catch the code on the Handlers success. I dont see an OnComplete, done method to subscribe too.</p> <p>Here is my Handler..</p> <pre><code> public class FileUpload : IHttpHandler { public void ProcessRequest(HttpContext context) { if (context.Request.Files.Count == 0) { LogRequest("No files sent."); context.Response.ContentType = "text/plain"; context.Response.Write("No files received."); } else { HttpPostedFile uploadedfile = context.Request.Files[0]; string FileName = uploadedfile.FileName; string FileType = uploadedfile.ContentType; int FileSize = uploadedfile.ContentLength; LogRequest(FileName + ", " + FileType + ", " + FileSize); string theName=uploadedfile.FileName.Substring(uploadedfile.FileName.LastIndexOf('\\')); uploadedfile.SaveAs(HttpContext.Current.Server.MapPath("/Upload") + theName); context.Response.ContentType = "text/plain"; context.Response.Write("{\"name\":\"" + FileName + "\",\"type\":\"" + FileType + "\",\"size\":\"" + FileSize + "\"}"); context.Response.Write("Hi From Handler"); } } public bool IsReusable { get { return false; } } </code></pre> <p>Here is my client code..</p> <pre><code> &lt;script&gt; /*global $ */ $(function () { $('#file_upload').fileUploadUI({ url: 'FileUpload.ashx', method: 'POST', uploadTable: $('#files'), downloadTable: $('#files'), buildUploadRow: function (files, index) { return $('&lt;tr&gt;&lt;td&gt;' + files[index].name + '&lt;\/td&gt;' + '&lt;td class="file_upload_progress"&gt;&lt;div&gt;&lt;\/div&gt;&lt;\/td&gt;' + '&lt;td class="file_upload_cancel"&gt;' + '&lt;button class="ui-state-default ui-corner-all" title="Cancel"&gt;' + '&lt;span class="ui-icon ui-icon-cancel"&gt;Cancel&lt;\/span&gt;' + '&lt;\/button&gt;&lt;\/td&gt;&lt;\/tr&gt;'); }, buildDownloadRow: function (file) { return $('&lt;tr&gt;&lt;td&gt;' + file.name + '&lt;\/td&gt;&lt;\/tr&gt;'); }, parseResponse: function (data) { alert("yo"); } }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload