Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 从httphandler返回多个参数到FineUploader`OnComplete`_Json_Httphandler_Fine Uploader - Fatal编程技术网

Json 从httphandler返回多个参数到FineUploader`OnComplete`

Json 从httphandler返回多个参数到FineUploader`OnComplete`,json,httphandler,fine-uploader,Json,Httphandler,Fine Uploader,Im使用FineUploder将图像上载到web服务器 javascript function createUploader() { var thumbnailuploader = new qq.FineUploader({ element: $('#thumbnail-fine-uploader')[0], request: {

Im使用FineUploder将图像上载到web服务器

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;

这里我需要返回另一个带有json响应的参数。如何将另一个参数添加到
context.Response.Write(“{\”success\”:true}”)并从javascript“onComplete”方法读取它

您可以在JSON消息中添加另一个字段,如下所示:

Write(“{\'success\':true,\'myParam\':\'awesome\'”)

onComplete()
方法有一个
responseJSON
参数,您可以从中检索字段的值。请参阅此处的文档:


另请参见关于onComplete()方法的回答。onComplete方法中的第一个参数是event,尽管文档中没有提到它。
 public void ProcessRequest(HttpContext context)
    {
        .....

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