I’m using ajax-upload in a ASP.Net forms app.
I need to send a string hash which identifies the file once it is saved on the server.
I’m doing it in the ashx handler emitting a json string, but no matter what i send from the server, in the javascript i’m getting an empty object… what am I doing wrong?
This is the snippet for the on load method on the ashx
// EDITED
context.Response.ContentType = “application/json”;
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
ProcessFile(context.Response);
context.Response.Write("{\"success\": true, \"hash\": " + _myHash + "}");
And this is the on complete
onComplete: function(id, file, responseJSON) {
console.log(responseJSON);
}
These are the changes i had to do to the fileuploader.js file so it could work:
I also changed the way it emits the response in case of JSON errors: