0

Im using FineUploder to upload an image to web server.

javascript

    function createUploader() {
                    var thumbnailuploader = new qq.FineUploader({
                        element: $('#thumbnail-fine-uploader')[0],
                        request: {
                            endpoint: '<%= ResolveUrl("~/Common/uploadhandler.ashx") %>'
                        },
                        multiple: false,

                        ...

                        callbacks: {
                            onComplete: function (id, fileName, responseJSON) {
                                if (responseJSON.success) {
                                    $('#imgPreview').html('<img src="../Uploaded/' + filename + '" alt="' + filename + '">');
                                }
                            }
                        }
                    });
                }

                window.onload = createUploader;

javascript calls Serverside uploadhandler.ashx, and uploads the file successfully .

 public void ProcessRequest(HttpContext context)
    {
        .....

        context.Response.ContentType = "application/json";
        context.Response.Write("{\"success\":true}");
    }

Here I need to return another parameter with the json response. How to add another parameter to context.Response.Write("{\"success\":true}"); and read it from the javascript 'onComplete' method

Nalaka526
  • 11,278
  • 21
  • 82
  • 116

1 Answers1

2

You can add another field in your JSON message like so:

context.Response.Write("{\"success\":true, \"myParam\":\"awesome\"}");

The onComplete() method has a responseJSON parameter from which you can retrieve the value of your field. See documentation here:

http://docs.fineuploader.com/api/callbacks.html

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
JNo
  • 395
  • 1
  • 4
  • 1
    Also see this answer about the onComplete() method. The first parameter in the onComplete method is event, though it isn't mentioned in the documentation. http://stackoverflow.com/questions/15528306/fineuploader-responsejson-doesnt-contain-success-in-oncomplete-callback – JNo Mar 20 '13 at 17:27