... 확인할 필요가있는 요소의 맥락에서?로드 (fn)와 준비 (fn)의 차이점
내가 jQuery를하지 않고은 iframe을 사용하여 업로드의 문제를 직면 한 적이 있지만, 지금은 형태, iframe이 포함 아약스 콜백에서 업로드에 대한 생각 :
<form enctype="multipart/form-data" action="get.imageupload.php" id="upload_form" method="post">
<input name="userfile" type="file" id="file" />
<input type="submit" name="action" value="start" />
<input type="hidden" name="id" value="<?=$id;?>" />
<iframe id="upload_target" name="upload_target" src="" style="width:0;height:0;border:0"></iframe>
</form>
을 다음과 같은 JS :
$("#upload_form").submit(function() {
$(this).attr("target","upload_target");
$("iframe", this).load(function() {
var ret = $("iframe", "#upload_form").contents().find("body").html();
var data = eval("("+ret+")");
if (data.success) alert("success"); // todo
if (data.failure) alert("fail"); // todo
});
return false;
});
get.imageupload.php
에서 JSON 데이터를 반환하는 요청을 처리해야하므로 js가 그렇게 보입니다. 문제 : load(fn)
가 작동하지 않습니다. ready(fn)
대신에 iframe
이 비어 있습니다. 왜냐하면 업로드가 시작되기 전에 이벤트가 발생하기 때문입니다 ... 저는 jQuery에서 초보자이고 다른 방법이 있을까요?
아이디어가 있으십니까?
모든 컨텐츠에로드 사업부 또는 이와 유사한 대신은 iframe을 사용하는 것이 왜 표시되지 않습니다
P. IE 브라우저가 아닙니다. – Vov4ik