(function($, undefined) {
"use strict";
// use this transport for "binary" data type
$.ajaxTransport("+binary", function(options, originalOptions, jqXHR) {
// check for conditions and support for blob / arraybuffer response type
if (window.FormData && ((options.dataType && (options.dataType == 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))) {
return {
// create new XMLHttpRequest
send: function(headers, callback) {
// setup all variables
var xhr = new XMLHttpRequest(),
url = options.url,
type = options.type,
async = options.async || true,
// blob or arraybuffer. Default is blob
dataType = options.responseType || "blob",
data = options.data || null,
username = options.username || null,
password = options.password || null;
xhr.addEventListener('load', function() {
var data = {};
data[options.dataType] = xhr.response;
// make callback and send data
callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
});
xhr.addEventListener('error', function() {
var data = {};
data[options.dataType] = xhr.response;
// make callback and send data
callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
});
xhr.open(type, url, async, username, password);
// setup custom headers
for (var i in headers) {
xhr.setRequestHeader(i, headers[i]);
}
xhr.responseType = dataType;
xhr.send(data);
},
abort: function() {}
};
}
});
})(window.jQuery);
$.ajax({
type: "POST",
url: "../report.php",
data: formData,
dataType: 'binary',
processData: false,
success: function (resp, status, xhr) {
var disposition = xhr.getResponseHeader('Content-Disposition');
var filename = disposition.substring(disposition.indexOf('filename=') + 'filename='.length).replace(/['"]/g, '');
var type = xhr.getResponseHeader('Content-Type');
var blob = new Blob([resp], {type: type});
var download_url = (window.URL || window.webkitURL).createObjectURL(blob);
var a = document.createElement("a");
a.href = download_url;
a.download = filename;
document.body.appendChild(a);
a.click();
},
error: function (xhr) {
...
}
});
var p1105 = parseInt($(".p1105").val());
....
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
<!doctype html>
<html>
<head>
<title>CSS Hover</title>
<link rel="stylesheet" href="hover.css">
</head>
<body>
<div class="container">
<span class="color-black">Black</span>
<span class="color-red">Red</span>
<span class="color-green">Green</span>
<div class="image"></div>
</div>
</body>
</html>
div.image {
width: 100px;
height: 75px;
}
span.color-black:hover ~ div.image {
background-image: url(black.png);
}
span.color-red:hover ~ div.image {
background-image: url(red.png);
}
span.color-green:hover ~ div.image {
background-image: url(green.png);
}