jquery call to get file stream file

。。。。:
function workDownLoad(workID) {
var fileName = "";
var status = false;
$.ajax({
type: "Post",
url: "/Common/GetWorkOrPlayName",
datatype: "json",
data: {
id: workID,
type: 0
},
async: false,
success: function (data) {
if (data.status == 0) {
fileName = data.WorkName;
status = true;
} else {
status = false;
}

},
error: function () { }
});

if (!status) {
return;
}

URL = var "/ the Common / WorkDownLoad /" + WorkId;
var = new new XHR the XMLHttpRequest ();
xhr.open ( 'the GET', URL, to true); // GET request, the request address, whether asynchronous
xhr.responseType = "blob "; // return type BLOB
xhr.onload = function (Data, textStatus, request) {// completion of the request handler
IF (=== 200 is this.status) {
var = this.response BLOB; // Get return value
var document.createElement = A ( 'A');
// var name = request.getResponseHeader ( 'the Content-Disposition');
a.download = fileName;
a.href = window.URL.createObjectURL (BLOB);
a.click ( );
}
};
// send ajax request
xhr.send ();

}

Jack:
????

Guess you like

Origin www.cnblogs.com/chuangli/p/12364379.html