function closeMe() { window.opener.location.reload(); setTimeout('window.close()', 100); } $(function () { var x1 = 0, y1 = 0, tw = 0, th = 0, rw = , //preview width; rh = ; //preview height //setvalues //Calling imgAreaSelect plugin var ias = $('img#imgc').imgAreaSelect({ handles: false, onSelectEnd: setValue, fadeSpeed: 200, minWidth: 40, minHeight: 40, }); //setvalue function function setValue(img, selection) { if (!selection.width || !selection.height) return; x1 = selection.x1; y1 = selection.y1; tw = selection.width; th = selection.height; } //ajax request get the function getCImage() { $("#cropbtn").addClass("disabled").html("croping..."); $.ajax({ type: "GET", url: "imageCrop_process.php?srcImg=" + $("#srcImg").val() + "&destDir=" + $("#destDir").val() + "&w=" + tw + "&h=" + th + "&x1=" + x1 + "&y1=" + y1 + "&rw=" + rw + "&rh=" + rh, cache: false, success: function (response) { $("#button").html(""); $("#button").html("Cropping was successful. Click close below.
"); ; }, error: function () { alert("crop failed"); }, }); } //will triger on crop button click $("#cropbtn").click(function () { getCImage(); }); });