Search code examples
jsonhttp-redirectcgijquery-file-upload

How to send json response in redirect url for jquery file upload


I am using blueimp file upload and on server side i am using cgi script.I am able to upload the file and getting valid json data.Now what i want is to sent this json data to the redirect url so i can do further procession on the redirect page.

My js code in jsp page is as follows:-

$(function () {
    //alert(window.location.hostname);
    'use strict';
    var urlTemp = '<%=actionStr%>';
    var successurl = '<%=successURL%>';
    $('#fileupload').fileupload(
            {
                url: urlTemp,
                sequentialUploads: true,
                redirect: successurl,
                type: 'POST'
            }
        );
    $('#fileupload').bind('fileuploadstop', 
            function (e, data) {
                data.formdata = data.result;
                alert(data);
                alert(data.formdata); //getting undefined
                window.location.href = successurl;

            }
    );
    $('#fileupload').fileupload('option','url');
});

in fileuploadstop event i am getting data.result as 'undefined'.


Solution

  • Try doing it like this:

    $('#fileupload').bind('fileuploaddone', function (e, data) {
      var results = data.result;
    });