本文介绍了未被捕获的typeerror jcrop不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:









< script src ="〜/ Script / jquery-1.11.3.min.js">< / script>



< link href ="〜 /Css/jquery.Jcrop.min.css"的rel ="样式表" />

< script src ="〜/ Script / jquery.Jcrop.min.js">< / script>







< p>< a href ="#" id =" hl-crop-image">剪裁图片< / a>< / p>



< p>

< img id =" my-origin-image" SRC ="〜/图像/ funny_cat_v1.jpg" />

< / p>

< p>

< img id =" my-cropped-image" SRC ="#"风格= QUOT;显示:无;" />

< / p>



@section scripts {



< script type =" text / javascript">



var imageCropWidth = 0;

var imageCropHeight = 0;

var cropPointX = 0;

var cropPointY = 0;



$(文件).ready(function( ){

initCrop();

});



$(&#; hl-crop- image")。on(" click",function(e){

e.preventDefault();

cropImage();

});



函数initCrop(){

$('#my-origin-image')。Jcrop({

onChange:setCoordsAndImgSize,

aspectRatio:1

});

}



function setCoordsAndImgSize(e){



imageCropWidth = ew;

imageCropHeight = eh;



cropPointX = ex;

cropPointY = ey;

}



函数cropImage( ){



if(imageCropWidth == 0&& imageCropHeight == 0){

alert(" Please select crop area。);

return;

}



$ .ajax({

url:'/ Image / CropImage',

类型:'POST',

数据:{

imagePath:$(&#; my-origin-image")。attr(" src"),

cropPointX: cropPointX,

cropPointY:cropPointY,

imageCropWidth:imageCropWidth,

imageCropHeight:imageCropHeight

},

成功:函数(数据){

$(&#; my-cropped-image")

.attr(" src",data。 photoPath +"?t =" + new Date()。getTime())

.show();

},

错误:函数(数据){}

});

}



< / script>

}

< / body>

< / html>







请帮助我

在此先感谢

the code is given below




<script src="~/Script/jquery-1.11.3.min.js"></script>

<link href="~/Css/jquery.Jcrop.min.css" rel="stylesheet" />
<script src="~/Script/jquery.Jcrop.min.js"></script>



<p><a href="#" id="hl-crop-image">Crop Image</a></p>

<p>
<img id="my-origin-image" src="~/Images/funny_cat_v1.jpg" />
</p>
<p>
<img id="my-cropped-image" src="#" style="display:none;" />
</p>

@section scripts{

<script type="text/javascript">

var imageCropWidth = 0;
var imageCropHeight = 0;
var cropPointX = 0;
var cropPointY = 0;

$(document).ready(function () {
initCrop();
});

$("#hl-crop-image").on("click", function (e) {
e.preventDefault();
cropImage();
});

function initCrop() {
$('#my-origin-image').Jcrop({
onChange: setCoordsAndImgSize,
aspectRatio: 1
});
}

function setCoordsAndImgSize(e) {

imageCropWidth = e.w;
imageCropHeight = e.h;

cropPointX = e.x;
cropPointY = e.y;
}

function cropImage() {

if (imageCropWidth == 0 && imageCropHeight == 0) {
alert("Please select crop area.");
return;
}

$.ajax({
url: '/Image/CropImage',
type: 'POST',
data: {
imagePath: $("#my-origin-image").attr("src"),
cropPointX: cropPointX,
cropPointY: cropPointY,
imageCropWidth: imageCropWidth,
imageCropHeight: imageCropHeight
},
success: function (data) {
$("#my-cropped-image")
.attr("src", data.photoPath + "?t=" + new Date().getTime())
.show();
},
error: function (data) { }
});
}

</script>
}
</body>
</html>



pls help me
Thanks in advance

推荐答案




这篇关于未被捕获的typeerror jcrop不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 12:49