【发布时间】:2013-08-23 11:18:58
【问题描述】:
由于兼容性,我已经使用 iframe 实现了 AJAX 上传,但是我现在尝试将 AJAX 上传返回的结果与 jcrop 绑定,因为结果是在之后加载的。
PHP 输出格式如下:
<img src="upload/'.$new_name.'" id="cropbox" />
<!-- This is the form that our event handler fills -->
<form action="crop.php" method="post" onsubmit="return checkCoords();">
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="submit" value="Crop Image" class="btn btn-large btn-inverse" />
</form>
我的问题是jcrop 没有与图像绑定。
这是因为绑定它的jQuery应该在AJAX上传发布结果之后运行吗?还是应该自动绑定图片?
jcrop的JSenter code here如下:
<script type="text/javascript">
$(function(){
$('#cropbox').Jcrop({
aspectRatio: 1,
onSelect: updateCoords
});
});
function updateCoords(c)
{
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
function checkCoords()
{
if (parseInt($('#w').val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
</script>
谁能告诉我为什么js没有与图像绑定?或者提供什么建议?
【问题讨论】:
标签: php jquery ajax iframe jcrop