目前,我的表单元素看起来像如下:如何通过xhrPost()发送一个csv文件?
<form enctype="multipart/form-data" name="copyReplaceForm" method="POST" action="/app/applications/copyreplace/postCsv">
但不是在<form>
给予action
,enctype
和method
,我想用dojo.xhrPost()
来发送。
有人请告诉我如何使用xhrPost
发送?
而且,我的休息这段代码看起来象下面这样:
@POST
@Path("/bulkCopyReplaceFirst")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.MULTIPART_FORM_DATA)
我xhrPost看起来像下面
var result;
dojo.xhrPost({
url :"/CopyReplace/bulkCopyR",
preventCache: true,
contentType : "multipart/form-data",
load: function(response) {
txtResponse = response;
console.log("response is : txtResponse"+txtResponse)
},
error: function(error, ioArgs) {
console.log("postImageOptions() ERROR :: " + error);
console.log("postImageOptions() ioArgs :: " + ioArgs);
return error;
}
});
}
(// meta.stackoverflow.com/q/251361) – Tushar
感谢编辑@Tushar – PPH
你可能会发现这个[这](HTTP [我如何格式化我的代码块?]://计算器。 com/questions/14459618/multipart-form-data-ajax-request-in-dojo)有帮助 – Dheeresh