Uploadify: show error message from HTTP response

前端 未结 4 1748
时光取名叫无心
时光取名叫无心 2020-11-30 07:32

If the server returns an error (HTTP response code != 200) when uploading a file with Uploadify, the uploaded file gets a red background and a message is show like this:

4条回答
  •  日久生厌
    2020-11-30 08:23

    For uploadify version 3.0+ take a look at the onUploadSuccess option - specifically the passed in variable named data - that will have whatever the server echoed. If you echo JSON remember to decode it like so:

    ...
    'onUploadSuccess' : function(file, data, response) {
        if (response){
            var json_data=JSON.decode(data);
            /* code here */
        }
    },
    ....
    

提交回复
热议问题