estoy usando jcrop para recortar la imagen en mis application.I php estoy usando a continuación código para pasar los valores y la ruta de la imagen de coordenadas usando ajax,¿Cómo obtengo la imagen usando jquery ajax?
function checkCoords(index) { if (parseInt(jQuery('#w').val())){ jQuery.ajax({ type : "POST", cache: false, dataType: 'html', data : { x : jQuery('#x').val(), y : jQuery('#y').val(), w : jQuery('#w').val(), h : jQuery('#h').val(), image_path : jQuery('#jc-hidden-image'+index).attr('src') }, url : BASE_URL+'apps/configure/cropimage', success : function(response) { jQuery(".preview_crop").html(response); } }); } else{ alert('Please select a crop region then press Crop button.'); }
En Controlador, utilizo el valor ajax como es abajo,
public function cropimageAction(){
$params = $this->getRequest()->getParams();
//d($params);
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = $params['image_path'];
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
$image = imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
header('Content-type: image/jpeg');
imagejpeg($dst_r,null,$jpeg_quality);
exit;
}
}
me dio la respuesta no es algo así como
( ( (
En lugar de la imagen recortada, tiene algún símbolo. Necesidad de obtener una imagen recortada en una respuesta ajax. ¿Qué hice mal en esto?
Gracias Está trabajando ahora – mymotherland