2

互換性のために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 アップロードが結果を公開した後にバインドする必要があるためですか? それとも、自動的に画像にバインドする必要がありますか?

の JSenter code hereは次のjcropとおりです。

<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が画像にバインドされていない理由を誰かアドバイスできますか? またはアドバイスを提供しますか?

4

1 に答える 1