Skip to content

Instantly share code, notes, and snippets.

@myf
Created April 7, 2017 04:01
Show Gist options
  • Save myf/21fdb87ecc5bec531eb635886ea7038d to your computer and use it in GitHub Desktop.
Save myf/21fdb87ecc5bec531eb635886ea7038d to your computer and use it in GitHub Desktop.
$(function () {
$("#b").click(testPOST);
var exportUrl = 'http://localhost:7801/';
function testPOST() {
var options = {
"xAxis": {
"categories": ["Jan", "Feb", "Mar","Apr"]
},
"series": [{
"data": [101.1, 71.5, 106.4]
}]
};
var send_json = {
"type": "image/png",
"width": 400,
"b64": true,
"options": options
};
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: exportUrl,
data: JSON.stringify(send_json),
mimeType: "text/plain; charset=x-user-defined",
success: function (data) {
debugger;
console.log('get the file from relative url: ', data);
$('#container').html('<img src="data:image/jpeg;base64,' + data + '"/>');
},
error: function (err) {
console.log('error', err.statusText);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment