我正在使用croppie jquery插件。所有事情都很顺利。调整图像大小后,我无法从promise对象获取dataurl。请帮助我。 这是我点击按钮时获得的数据的屏幕截图。 http://prntscr.com/awi9co
守则在
之下var basic = $('#divLoadLogo').croppie({
viewport: {
width: 150,
height: 50
},
enableOrientation: true
});
basic.croppie('bind', {
url: Url,
points: [77, 469, 280, 739],
});
$("#SaveResizeImage").click(function() {
var CanvasData = basic.croppie('result', 'canvas'); //This contains the promise object
$.ajax({
type: 'POST',
url: '/User/SaveResizedCanvasImage',
data: '{ "imageData" : "' + CanvasData + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
success: function(data) {
if (data.success) {
alert('image is resized');
}
}
});
});
答案 0 :(得分:0)
尝试:
var basic = $('#divLoadLogo').croppie({
viewport: {
width: 150,
height: 50
},
enableOrientation: true
});
basic.croppie('bind', {
url: Url,
points: [77, 469, 280, 739],
});
$("#SaveResizeImage").click(function() {
basic.croppie('result', 'canvas').then(function(CanvasData){
$.ajax({
type: 'POST',
url: '/User/SaveResizedCanvasImage',
data: '{ "imageData" : "' + CanvasData + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
success: function(data) {
if (data.success) {
alert('image is resized');
}
}
});
});
});