我在我的应用程序中使用异步Kendo UI Upload(docs),在服务器端使用HTML前端和Java servlet。当servlet没有返回任何响应时,它的工作正常。上传会在成功时将进度更改为“完成”,调用complete
回调方法。
我需要在成功上传时从服务器返回一些数据,例如GUID="SDR2334"
。当我从servlet发送响应时,Kendo UI Upload控件无法正常工作/呈现/ shown in Kendo demo site。
complete
方法未被调用我尝试使用响应标头而不是响应主体添加GUID。它还没有用。
<form method="post" action="submit" style="width:45%">
<div class="demo-section">
<input name="files" id="files" type="file" />
</div>
</form>
$("#files").kendoUpload({
async: {
saveUrl: "http:111.11.11.111/fileupload",
autoUpload: false
},
multiple: false,
showFileList: true,
upload: function (e) {
e.data = { sessionid: CurrentSession.sessionId };
},
complete: function (e) {
alert(e.data);
$(".k-widget.k-upload").find("ul").remove();
}
});
Key Value Request POST /services/fileUploadWithoutResponse HTTP/1.1 Accept application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Referer http://111.11.11.11:8090/WebClient/ Accept-Language en-US User-Agent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) Content-Type multipart/form-data; boundary=---------------------------7de38b1219073a Accept-Encoding gzip, deflate Host 172.16.17.100:8090 Content-Length 114034 DNT 1 Connection Keep-Alive Cache-Control no-cache
Key Value Response HTTP/1.1 200 OK Server Apache-Coyote/1.1 X-Powered-By Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Access-Control-Allow-Origin * guId f6ac7203-5bd6-433b-a632-548ca5b048cf Content-Type application/json;charset=utf-8 Content-Length 0 Date Fri, 03 Jan 2014 13:00:19 GMT
请注意guId
标题。
答案 0 :(得分:0)
我是通过将响应内容类型设置为text / plain来实现的。
此外,我意识到我需要success
event而不是complete
event来获取响应正文的内容(e.response
)。